[BUGFIX] Fix broken language flags via IconUtility::getSpriteIcon 61/49161/4
authorFrank Naegler <frank.naegler@typo3.org>
Fri, 22 Jul 2016 08:03:10 +0000 (10:03 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 6 Aug 2016 17:57:47 +0000 (19:57 +0200)
With #70477 the SpriteIcon stuff has been marked as deprecated.
The patch removed the flags support. This patch fix the problem by checking
the IconRegisty and return the icon by using the IconFactory.

Resolves: #76996
Related: #70477
Releases: 7.6
Change-Id: I0323c6bc132eb9a8049294ee66ac3cf37d10f9fd
Reviewed-on: https://review.typo3.org/49161
Reviewed-by: Thomas Mayer <thomas.mayer@2bis10.de>
Tested-by: Thomas Mayer <thomas.mayer@2bis10.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Utility/IconUtility.php

index 7bf14e5..f6123f3 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Utility;
 use TYPO3\CMS\Core\Imaging\GraphicalFunctions;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Imaging\IconRegistry;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
 
@@ -596,6 +597,15 @@ class IconUtility
     public static function getSpriteIcon($iconName, array $options = array(), array $overlays = array())
     {
         GeneralUtility::logDeprecatedFunction();
+
+        // First check if an icon is registered in IconRegistry and
+        // return if icon is available.
+        $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
+        if ($iconRegistry->isRegistered($iconName)) {
+            $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
+            return $iconFactory->getIcon($iconName, Icon::SIZE_SMALL)->render();
+        }
+
         // Check if icon can be cached and return cached version if present
         if (empty($options) && empty($overlays)) {
             if (isset(static::$spriteIconCache[$iconName])) {