[BUGFIX] Add icon rendering for custom permissions options 67/48967/11
authorBenjamin Serfhos <serfhos@gmail.com>
Wed, 13 Jul 2016 21:06:14 +0000 (23:06 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Mon, 31 Oct 2016 13:09:42 +0000 (14:09 +0100)
The icon rendering of custom page options was lost during
refactoring of the ItemProviders.

Resolves: #77075
Releases: master, 7.6
Change-Id: Iae6415525d94fc56c48332de9e5bc3980344fbc2
Reviewed-on: https://review.typo3.org/48967
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php
typo3/sysext/core/Classes/Imaging/IconRegistry.php

index dccd136..353c97d 100644 (file)
@@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Database\Query\QueryHelper;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\RelationHandler;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Imaging\IconRegistry;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
@@ -159,6 +160,7 @@ abstract class AbstractItemProvider
         }
 
         $languageService = $this->getLanguageService();
+        $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
         $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
 
         $special = $result['processedTca']['columns'][$fieldName]['config']['special'];
@@ -292,6 +294,12 @@ abstract class AbstractItemProvider
                             foreach ($coValue['items'] as $itemKey => $itemCfg) {
                                 $icon = 'empty-empty';
                                 $helpText = [];
+                                if (!empty($itemCfg[1])) {
+                                    if ($iconRegistry->isRegistered($itemCfg[1])) {
+                                        // Use icon identifier when registered
+                                        $icon = $itemCfg[1];
+                                    }
+                                }
                                 if (!empty($itemCfg[2])) {
                                     $helpText['description'] = $languageService->sL($itemCfg[2]);
                                 }
index 6a53c28..668b37a 100644 (file)
@@ -1093,6 +1093,11 @@ class TcaSelectItemsTest extends UnitTestCase
                     'anItemKey' => [
                         0 => 'anItemTitle',
                     ],
+                    'anotherKey' => [
+                        0 => 'anotherTitle',
+                        1 => 'status-status-permission-denied',
+                        2 => 'aDescription',
+                    ],
                 ],
             ]
         ];
@@ -1110,6 +1115,12 @@ class TcaSelectItemsTest extends UnitTestCase
                 2 => 'empty-empty',
                 3 => null,
             ],
+            2 => [
+                0 => 'anotherTitle',
+                1 => 'aKey:anotherKey',
+                2 => 'status-status-permission-denied',
+                3 => [ 'description' => 'aDescription' ],
+            ],
         ];
 
         $result = $this->subject->addData($input);
index 269561b..92eea13 100644 (file)
@@ -2995,7 +2995,7 @@ class IconRegistry implements SingletonInterface
      * @param string $iconReference
      * @return string
      */
-    protected function detectIconProvider($iconReference)
+    public function detectIconProvider($iconReference)
     {
         if (StringUtility::endsWith(strtolower($iconReference), 'svg')) {
             return SvgIconProvider::class;