ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
hasSymbolTrait.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use LogicException;
27
33{
34 protected ?Symbol $symbol = null;
35
39 public function withSymbol(Symbol $symbol): hasSymbol
40 {
41 // bugfix mantis 25526: make aria labels mandatory
42 if (($symbol instanceof Glyph && $symbol->getAriaLabel() === "") ||
43 ($symbol instanceof Icon && $symbol->getLabel() === "")) {
44 throw new LogicException("the symbol's aria label MUST be set to ensure accessibility");
45 }
46
47 $clone = clone $this;
48 $clone->symbol = $symbol;
49
50 return $clone;
51 }
52
56 public function getSymbol(): Symbol
57 {
58 return $this->symbol;
59 }
60
64 public function hasSymbol(): bool
65 {
66 return $this->symbol instanceof Symbol;
67 }
68}
This describes a symbol.
Definition: Symbol.php:30
getLabel()
Get the label of this icon.
trait hasSymbolTrait
Trait hasSymbolTrait.
withSymbol(Symbol $symbol)
@inheritDoc