alternativeMarkups[$alternativeMarkupIdentifier])) { return $this->alternativeMarkups[$alternativeMarkupIdentifier]; } return $this->markup; } /** * @return $this */ public function setMarkup(string $markup): self { $this->markup = $markup; return $this; } public function getAlternativeMarkup(string $markupIdentifier): string { return $this->alternativeMarkups[$markupIdentifier] ?: ''; } /** * @return $this */ public function setAlternativeMarkup(string $markupIdentifier, string $markup): self { $this->alternativeMarkups[$markupIdentifier] = $markup; return $this; } public function getIdentifier(): string { return $this->identifier; } /** * @return $this */ public function setIdentifier(string $identifier): self { $this->identifier = $identifier; return $this; } public function getTitle(): ?string { return $this->title; } /** * @return $this */ public function setTitle(?string $title): self { $this->title = $title; return $this; } public function getOverlayIcon(): ?Icon { return $this->overlayIcon; } /** * @return $this */ public function setOverlayIcon(?Icon $overlayIcon): self { $this->overlayIcon = $overlayIcon; return $this; } public function getSize(): string { return $this->size->value; } /** * Sets the size and creates the new dimension */ public function setSize(IconSize $size): self { $this->size = $size; $this->dimension = GeneralUtility::makeInstance(Dimension::class, $size); return $this; } public function isSpinning(): bool { return $this->spinning; } /** * @return $this */ public function setSpinning(bool $spinning): self { $this->spinning = $spinning; return $this; } public function isBidi(): bool { return $this->bidi; } /** * @return $this */ public function setBidi(bool $bidi): self { $this->bidi = $bidi; return $this; } public function getState(): IconState { return $this->state; } /** * @return $this */ public function setState(IconState $state): self { $this->state = $state; return $this; } public function getDimension(): Dimension { return $this->dimension; } public function render(?string $alternativeMarkupIdentifier = null): string { $overlayIconMarkup = ''; if ($this->overlayIcon !== null) { $overlayIconMarkup = '' . $this->overlayIcon->getMarkup() . ''; } return str_replace('{overlayMarkup}', $overlayIconMarkup, $this->wrappedIcon($alternativeMarkupIdentifier)); } public function __toString(): string { return $this->render(); } /** * Wrap icon markup in unified HTML code */ protected function wrappedIcon(?string $alternativeMarkupIdentifier = null): string { $classes = []; $classes[] = 't3js-icon'; $classes[] = 'icon'; $classes[] = 'icon-size-' . $this->getSize(); $classes[] = 'icon-state-' . htmlspecialchars($this->state instanceof IconState ? $this->state->value : IconState::STATE_DEFAULT->value); $classes[] = 'icon-' . $this->getIdentifier(); if ($this->isSpinning()) { $classes[] = 'icon-spin'; } if ($this->isBidi()) { $classes[] = 'icon-bidi'; } $attributes = []; $attributes['title'] = $this->getTitle(); $attributes['class'] = implode(' ', $classes); $attributes['data-identifier'] = $this->getIdentifier(); $attributes['aria-hidden'] = 'true'; $markup = []; $markup[] = ''; $markup[] = ' '; $markup[] = $this->getMarkup($alternativeMarkupIdentifier); $markup[] = ' '; $markup[] = ' {overlayMarkup}'; $markup[] = ''; return implode(LF, $markup); } }