Deprecation: #104778 - Instantiation of IconRegistry in ext_localconf.php
See forge#104778
Description
Since TYPO3 v11 it is possible to automatically register own icons via
Configuration/
. Prior to this, extension authors used to register
icons manually via instantiating the php:\TYPO3\
in their ext_
files. This method has now been deprecated. It is recommended to switch to
the newer method introduced with forge#94692.
Impact
Instantiating
Icon
inside
ext_
files will trigger a deprecation-level log entry.
Affected installations
All installations, which instantiate
Icon
before the
\TYPO3\
. This includes
ext_
files as well as TCA/
.
Migration
The most common use-cases can be accomplished via the Configuration/
file.
Before:
<?php
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Imaging\IconRegistry::class,
);
$iconRegistry->registerIcon(
'example',
\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
[
'source' => 'EXT:example/Resources/Public/Icons/example.svg'
],
);
After:
<?php
return [
'example' => [
'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
'source' => 'EXT:example/Resources/Public/Icons/example.svg',
],
];
For more complex tasks, it is recommended to register an event listener for the
Boot
. At this stage the system
is fully booted and you have a completely configured IconRegistry at hand.
In case the registry was used in TCA/
files to retrieve icon
identifiers, then this should be replaced completely with static identifiers.
The reason behind this is, that the registry isn't even fully usable at this
stage. TCA isn't fully built yet and icons can still be registered at a later
point.