ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
hasSymbolTrait.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
21 
25 use LogicException;
26 
31 trait hasSymbolTrait
32 {
33  protected ?Symbol $symbol = null;
34 
38  public function withSymbol(Symbol $symbol): hasSymbol
39  {
40  // bugfix mantis 25526: make aria labels mandatory
41  if (($symbol instanceof Glyph && $symbol->getAriaLabel() === "") ||
42  ($symbol instanceof Icon && $symbol->getLabel() === "")) {
43  throw new LogicException("the symbol's aria label MUST be set to ensure accessibility");
44  }
45 
46  $clone = clone $this;
47  $clone->symbol = $symbol;
48 
49  return $clone;
50  }
51 
55  public function getSymbol(): Symbol
56  {
57  return $this->symbol;
58  }
59 
63  public function hasSymbol(): bool
64  {
65  return $this->symbol instanceof Symbol;
66  }
67 }
getLabel()
Get the label of this icon.
This describes a symbol.
Definition: Symbol.php:29
This describes how a glyph could be modified during construction of UI.
Definition: Glyph.php:30
Interface hasSymbol Methods for Entries with Symbols.
Definition: hasSymbol.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...