ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
Tool.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
4 
5 use Closure;
14 
20 {
21 
29  protected $symbol;
33  protected $content;
37  protected $content_wrapper;
41  protected $title;
45  protected $close_callback;
46 
51  public function withTitle(string $title) : hasTitle
52  {
53  $clone = clone($this);
54  $clone->title = $title;
55 
56  return $clone;
57  }
58 
62  public function getTitle() : string
63  {
64  return $this->title;
65  }
66 
71  {
72  $clone = clone($this);
73  $clone->content_wrapper = $content_wrapper;
74 
75  return $clone;
76  }
77 
81  public function withContent(Component $ui_component) : hasContent
82  {
83  $clone = clone($this);
84  $clone->content = $ui_component;
85 
86  return $clone;
87  }
88 
92  public function getContent() : Component
93  {
94  if ($this->content_wrapper !== null) {
95  $wrapper = $this->content_wrapper;
96 
97  return $wrapper();
98  }
99 
100  return $this->content;
101  }
102 
106  public function withSymbol(Symbol $symbol) : hasSymbol
107  {
108  // bugfix mantis 25526: make aria labels mandatory
109  if (($symbol instanceof Icon\Icon || $symbol instanceof Glyph\Glyph)
110  && ($symbol->getAriaLabel() === "")
111  ) {
112  throw new \LogicException("the symbol's aria label MUST be set to ensure accessibility");
113  }
114 
115  $clone = clone($this);
116  $clone->symbol = $symbol;
117 
118  return $clone;
119  }
120 
124  public function getSymbol() : Symbol
125  {
126  return $this->symbol;
127  }
128 
132  public function hasSymbol() : bool
133  {
134  return ($this->symbol instanceof Symbol);
135  }
136 
141  {
142  $clone = clone $this;
143  $clone->terminated_callback = $callback;
144 
145  return $clone;
146  }
147 
151  public function getTerminatedCallback() : ?Closure
152  {
154  }
155 
159  public function hasTerminatedCallback() : bool
160  {
161  return $this->terminated_callback instanceof Closure;
162  }
163 }
This describes a symbol.
Definition: Symbol.php:11
This describes how a icon could be modified during construction of UI.
Definition: Icon.php:9
This describes how a glyph could be modified during construction of UI.
Definition: Glyph.php:13
Interface hasSymbol Methods for Entries with Symbols.
Definition: hasSymbol.php:11
withTerminatedCallback(Closure $callback)
Definition: Tool.php:140
withContentWrapper(Closure $content_wrapper)
Definition: Tool.php:70
withContent(Component $ui_component)
Definition: Tool.php:81