/** * Render the icon as HTML code * * @param string $alternativeMarkupIdentifier * * @return string */ public function render($alternativeMarkupIdentifier = null) { $overlayIconMarkup = ''; if ($this->overlayIcon !== null) { $overlayIconMarkup = '<span class="icon-overlay icon-' . htmlspecialchars($this->overlayIcon->getIdentifier()) . '">' . $this->overlayIcon->getMarkup() . '</span>'; } return str_replace('{overlayMarkup}', $overlayIconMarkup, $this->wrappedIcon($alternativeMarkupIdentifier)); }
/** * @param Icon $icon * @param array $options * @return string * @throws \InvalidArgumentException */ protected function generateMarkup(Icon $icon, array $options) { if (empty($options['source'])) { throw new \InvalidArgumentException('[' . $icon->getIdentifier() . '] The option "source" is required and must not be empty', 1440754980); } $source = $options['source']; if (StringUtility::beginsWith($source, 'EXT:') || !StringUtility::beginsWith($source, '/')) { $source = GeneralUtility::getFileAbsFileName($source); } $source = PathUtility::getAbsoluteWebPath($source); return '<img src="' . htmlspecialchars($source) . '" width="' . $icon->getDimension()->getWidth() . '" height="' . $icon->getDimension()->getHeight() . '" />'; }
/** * @test */ public function getIdentifierReturnsCorrectIdentifier() { $this->assertEquals($this->iconIdentifier, $this->subject->getIdentifier()); }