Deprecation: #102895 - ExtensionManagementUtility::getExtensionIcon

See forge#102895

Description

The PHP method \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getExtensionIcon has been deprecated in favor of \TYPO3\CMS\Core\Package\Package->getPackageIcon.

Impact

Calling the method \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getExtensionIcon will trigger a PHP deprecation warning.

Affected installations

TYPO3 installations with custom extensions calling the method.

Migration

Migrate towards the PackageManager implementation, which can be added via Dependency Injection or retrieved via GeneralUtility::makeInstance().

Before

$iconPathInPackage = ExtensionManagementUtility::getExtensionIcon($extensionKey);
$fullIconPath = ExtensionManagementUtility::getExtensionIcon($extensionKey, true);

After

$packageManager = GeneralUtility::makeInstance(PackageManager::class);
$package = $packageManager->getPackage($extensionKey);
if ($package->getPackageIcon()) {
    $iconPathInPackage = $package->getPackageIcon();
    $fullIconPath = $package->getPackagePath() . $package->getPackageIcon();
}