From 77e580bf147732f4e838a7fed96550ca9699adb4 Mon Sep 17 00:00:00 2001
From: Stefan Galinski <stefan@sgalinski.de>
Date: Sun, 17 Jul 2016 23:50:45 +0200
Subject: [PATCH] [BUGFIX] Fix deprecated usage of the sprite manager

---
 ext_tables.php | 53 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 32 insertions(+), 21 deletions(-)

diff --git a/ext_tables.php b/ext_tables.php
index cbb67cb..564a6a3 100644
--- a/ext_tables.php
+++ b/ext_tables.php
@@ -33,6 +33,13 @@ TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
 	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:titlePageBrowserPlugin'
 );
 
+// Removal of the unused plugin setting fields
+$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_overview'] = 'select_key,pages,recursive';
+$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_listbycategory'] = 'select_key,pages,recursive';
+$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_latest'] = 'select_key,pages,recursive';
+$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_singleview'] = 'select_key,pages,recursive';
+$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_pagebrowser'] = 'select_key,pages,recursive';
+
 // Flex form assignment
 $pluginSignature = str_replace('_', '', 'sg_news') . '_overview';
 $TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
@@ -52,18 +59,21 @@ $TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_
 	$pluginSignature, 'FILE:EXT:sg_news/Configuration/FlexForms/Latest.xml'
 );
 
+// Define the new doktypes
+/** @var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */
+$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
+$relativeExtensionPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('sg_news');
+
 ###################################
 ### Define the Category Doktype ###
 ###################################
 
-$relativeExtensionPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('sg_news');
 $customPageDoktype = 117;
-$customPageIcon = $relativeExtensionPath . 'Resources/Public/Images/Category.png';
 
 // add the new doktype to the list of page types
 $GLOBALS['PAGES_TYPES'][$customPageDoktype] = [
 	'type' => 'sys',
-	'icon' => $customPageIcon,
+	'icon' => 'EXT:sg_news/Resources/Public/Images/Category.png',
 	'allowedTables' => '*',
 ];
 
@@ -71,18 +81,23 @@ $GLOBALS['PAGES_TYPES'][$customPageDoktype] = [
 $GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'][] = [
 	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageType.category',
 	$customPageDoktype,
-	$customPageIcon
+	'EXT:sg_news/Resources/Public/Images/Category.png'
 ];
 
 // also add the new doktype to the page language overlays type selector (so that translations can inherit the same type)
 $GLOBALS['TCA']['pages_language_overlay']['columns']['doktype']['config']['items'][] = [
 	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageType.category',
 	$customPageDoktype,
-	$customPageIcon
+	'EXT:sg_news/Resources/Public/Images/Category.png'
 ];
 
-// add the sprite icon for the new doktype
-\TYPO3\CMS\Backend\Sprite\SpriteManager::addTcaTypeIcon('pages', $customPageDoktype, $customPageIcon);
+// register new icon
+$iconRegistry->registerIcon(
+	'tcarecords-pages-' . $customPageDoktype,
+	\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
+	['source' => 'EXT:sg_news/Resources/Public/Images/Category.png']
+);
+$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$customPageDoktype] = 'tcarecords-pages-' . $customPageDoktype;
 
 // add the new doktype to the list of types available from the new page menu at the top of the page tree
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(
@@ -93,14 +108,12 @@ $GLOBALS['TCA']['pages_language_overlay']['columns']['doktype']['config']['items
 ### Define the News Doktype ###
 ###############################
 
-$relativeExtensionPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('sg_news');
 $customPageDoktype = 116;
-$customPageIcon = $relativeExtensionPath . 'Resources/Public/Images/News.png';
 
 // add the new doktype to the list of page types
 $GLOBALS['PAGES_TYPES'][$customPageDoktype] = [
 	'type' => 'sys',
-	'icon' => $customPageIcon,
+	'icon' => 'EXT:sg_news/Resources/Public/Images/News.png',
 	'allowedTables' => '*',
 ];
 
@@ -108,27 +121,25 @@ $GLOBALS['PAGES_TYPES'][$customPageDoktype] = [
 $GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'][] = [
 	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageType.news',
 	$customPageDoktype,
-	$customPageIcon
+	'EXT:sg_news/Resources/Public/Images/News.png'
 ];
 
 // also add the new doktype to the page language overlays type selector (so that translations can inherit the same type)
 $GLOBALS['TCA']['pages_language_overlay']['columns']['doktype']['config']['items'][] = [
 	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageType.news',
 	$customPageDoktype,
-	$customPageIcon
+	'EXT:sg_news/Resources/Public/Images/News.png'
 ];
 
-// add the sprite icon for the new doktype
-\TYPO3\CMS\Backend\Sprite\SpriteManager::addTcaTypeIcon('pages', $customPageDoktype, $customPageIcon);
+// register new icon
+$iconRegistry->registerIcon(
+	'tcarecords-pages-' . $customPageDoktype,
+	\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
+	['source' => 'EXT:sg_news/Resources/Public/Images/News.png']
+);
+$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$customPageDoktype] = 'tcarecords-pages-' . $customPageDoktype;
 
 // add the new doktype to the list of types available from the new page menu at the top of the page tree
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(
 	'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . $customPageDoktype . ')'
 );
-
-// Removal of the unused plugin setting fields
-$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_overview'] = 'select_key,pages,recursive';
-$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_listbycategory'] = 'select_key,pages,recursive';
-$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_latest'] = 'select_key,pages,recursive';
-
-?>
-- 
GitLab