/** * @param string $identifier * @param string $size "large", "small" or "default", see the constants of the Icon class * @param string $overlayIdentifier * @param IconState $state * @return Icon */ public function getIcon($identifier, $size = Icon::SIZE_DEFAULT, $overlayIdentifier = null, IconState $state = null) { if ($this->iconRegistry->isDeprecated($identifier)) { $deprecationSettings = $this->iconRegistry->getDeprecationSettings($identifier); GeneralUtility::deprecationLog(sprintf($deprecationSettings['message'], $identifier)); if (!empty($deprecationSettings['replacement'])) { $identifier = $deprecationSettings['replacement']; } } if (!$this->iconRegistry->isRegistered($identifier)) { $identifier = $this->iconRegistry->getDefaultIconIdentifier(); } $iconConfiguration = $this->iconRegistry->getIconConfigurationByIdentifier($identifier); $iconConfiguration['state'] = $state; $icon = $this->createIcon($identifier, $size, $overlayIdentifier, $iconConfiguration); /** @var IconProviderInterface $iconProvider */ $iconProvider = GeneralUtility::makeInstance($iconConfiguration['provider']); $iconProvider->prepareIconMarkup($icon, $iconConfiguration['options']); return $icon; }
/** * @test * @param $deprecationSettings * @param $expected * @dataProvider getIconReturnsReplacementIconWhenDeprecatedDataProvider */ public function getIconReturnsReplacementIconWhenDeprecated($deprecationSettings, $expected) { $this->iconRegistryMock->isDeprecated($this->registeredIconIdentifier)->willReturn(true); $this->iconRegistryMock->getDeprecationSettings($this->registeredIconIdentifier)->willReturn($deprecationSettings); $this->assertContains($expected, $this->subject->getIcon($this->registeredIconIdentifier, Icon::SIZE_SMALL)->render()); }