diff --git a/typo3/sysext/core/Classes/Imaging/IconRegistry.php b/typo3/sysext/core/Classes/Imaging/IconRegistry.php index 5a41dda32922be3e46454cf756b4b38c9e4ffdef..0586f7c27ae1c6364bb27e79c2d24b0097f982fb 100644 --- a/typo3/sysext/core/Classes/Imaging/IconRegistry.php +++ b/typo3/sysext/core/Classes/Imaging/IconRegistry.php @@ -195,12 +195,11 @@ class IconRegistry implements SingletonInterface * * Example: * [ - * 'deprecated-icon-identifier' => 'new-icon-identifier', - * 'another-deprecated-identifier' => null, + * 'deprecated-icon-identifier' => ['since' => 'TYPO3 v12', 'until' => 'TYPO3 v13', 'replacement' => 'new-icon-identifier'], + * 'another-deprecated-identifier' => ['since' => 'TYPO3 v12', 'until' => 'TYPO3 v13', 'replacement' => null], * ] * * @var array - * @deprecated These icons will be removed in TYPO3 v12 */ protected $deprecatedIcons = []; @@ -351,6 +350,10 @@ class IconRegistry implements SingletonInterface 'provider' => $iconProviderClassName, 'options' => $options, ]; + + if (isset($options['deprecated'])) { + $this->deprecatedIcons[$identifier] = $options['deprecated']; + } } /** @@ -404,14 +407,21 @@ class IconRegistry implements SingletonInterface $this->initialize(); } if ($this->isDeprecated($identifier)) { - $replacement = $this->deprecatedIcons[$identifier] ?? null; - if (!empty($replacement)) { - $message = 'The icon "%s" is deprecated since TYPO3 v9 and will be removed in TYPO3 v10.0. Please use "%s" instead.'; - $arguments = [$identifier, $replacement]; - $identifier = $replacement; - } else { - $message = 'The icon "%s" is deprecated since TYPO3 v9 and will be removed in TYPO3 v10.0.'; - $arguments = [$identifier]; + $deprecation = $this->deprecatedIcons[$identifier]; + $since = $deprecation['since'] ?? null; + $until = $deprecation['until'] ?? null; + $replacement = $deprecation['replacement'] ?? null; + + $message = 'The icon "%s" is deprecated%s%s.'; + $arguments = [ + $identifier, + $since !== null ? ' since ' . $since : '', + $until !== null ? ' and will be removed in ' . $until : '', + ]; + + if ($replacement) { + $message .= ' Please use "%s" instead.'; + $arguments[] = $replacement; } trigger_error(vsprintf($message, $arguments), E_USER_DEPRECATED); } diff --git a/typo3/sysext/core/Documentation/Changelog/12.0/Feature-98130-AllowDeprecationOfIconsInExtensions.rst b/typo3/sysext/core/Documentation/Changelog/12.0/Feature-98130-AllowDeprecationOfIconsInExtensions.rst new file mode 100644 index 0000000000000000000000000000000000000000..f73111b7471e97ed3c37c1e15604b1a99235c0e5 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/12.0/Feature-98130-AllowDeprecationOfIconsInExtensions.rst @@ -0,0 +1,46 @@ +.. include:: /Includes.rst.txt + +.. _feature-98130-1660295017: + +========================================================== +Feature: #98130 - Allow deprecation of icons in extensions +========================================================== + +See :issue:`98130` + +Description +=========== + +Extension authors are now able to deprecate icons if they are meant to be public +API. A new option :php:`deprecated` is introduced that may contain the following +data: + +* :php:`since` - since when is the icon deprecated +* :php:`until` - when will the icon be removed +* :php:`replacement` - if given, an alternative icon is offered + + +Impact +====== + +An extension that provides icons for broader use is now able to mark such icons +as deprecated properly with logging to the TYPO3 deprecation log. + +Example: + +.. code-block:: php + + // Configuration/Icons.php + return [ + 'deprecated-icon' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class, + 'source' => 'EXT:my_extension/Resources/Public/Icons/deprecated-icon.png', + 'deprecated' => [ + 'since' => 'my extension v2', + 'until' => 'my extension v3', + 'replacement' => 'alternative-icon', + ], + ], + ]; + +.. index:: Backend, ext:core