Example #1
0
 /**
  * @test
  */
 public function getIconConfigurationByIdentifierReturnsCorrectConfiguration()
 {
     $result = $this->subject->getIconConfigurationByIdentifier('default-not-found');
     // result must contain at least provider and options array
     $this->assertArrayHasKey('provider', $result);
     $this->assertArrayHasKey('options', $result);
     // the provider must implement the IconProviderInterface
     $this->assertTrue(in_array(IconProviderInterface::class, class_implements($result['provider'])));
 }
Example #2
0
 /**
  * @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;
 }
 /**
  * @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)
 {
     $cacheIdentifier = md5($identifier . $size . $overlayIdentifier . (string) $state);
     if (!empty(static::$iconCache[$cacheIdentifier])) {
         return static::$iconCache[$cacheIdentifier];
     }
     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']);
     static::$iconCache[$cacheIdentifier] = $icon;
     return $icon;
 }
 /**
  * @test
  */
 public function getIconReturnsCorrectMarkupIfIconIsRegisteredAsSpinningIcon()
 {
     $this->iconRegistryMock->getIconConfigurationByIdentifier($this->registeredSpinningIconIdentifier)->willReturn(['provider' => FontawesomeIconProvider::class, 'options' => array('name' => 'times-circle', 'additionalClasses' => 'fa-fw', 'spinning' => true)]);
     $this->assertContains('<span class="t3js-icon icon icon-size-default icon-state-default icon-' . $this->registeredSpinningIconIdentifier . ' icon-spin" data-identifier="spinning-icon">', $this->subject->getIcon($this->registeredSpinningIconIdentifier)->render());
 }