- Issue created by @kevinquillen
- Merge request !20Check for file_icon_class with the DeprecationHelper backwards compatible call. β (Merged) created by kevinquillen
- πΊπΈUnited States kevinquillen
It seems that phpstan is going to complain about missing classes or functions, but ultimately we cannot squelch that. The function was removed in 11, but the IconMimeType class does not exist until 10.3 so the pipeline warnings will persist.
Ultimately, this should work for all 3 versions:
if (!class_exists(DeprecationHelper::class)) { $icon_class = file_icon_class($mime_type); } else { $icon_class = DeprecationHelper::backwardsCompatibleCall( \Drupal::VERSION, '10.3', static fn () => IconMimeTypes::getIconClass($mime_type), static fn () => file_icon_class($mime_type) ); } $url_options['attributes'] = [ 'type' => "$mime_type; length={$file->getSize()}", 'title' => $filename, // Classes to add to the file field for icons. 'class' => [ 'file', // Add a specific class for each and every mime type. 'file--mime-' . strtr($mime_type, ['/' => '-', '.' => '-']), // Add a more general class for groups of well known MIME types. 'file--' . $icon_class, ], ];
-
kevinquillen β
committed b227f18d on 8.x-2.x
Issue #3451048 by kevinquillen: Handle deprecated function...
-
kevinquillen β
committed b227f18d on 8.x-2.x
- Status changed to Fixed
10 months ago 6:07pm 30 May 2024 Automatically closed - issue fixed for 2 weeks with no activity.