ILIAS  release_7 Revision v7.30-3-g800a261c036
Tool.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
21
22use Closure;
31use LogicException;
32
38{
42 protected $title;
50 protected $symbol;
54 protected $content;
62 protected $close_callback;
63
68 public function withTitle(string $title) : hasTitle
69 {
70 $clone = clone($this);
71 $clone->title = $title;
72
73 return $clone;
74 }
75
79 public function getTitle() : string
80 {
81 return $this->title;
82 }
83
88 {
89 $clone = clone($this);
90 $clone->content_wrapper = $content_wrapper;
91
92 return $clone;
93 }
94
98 public function withContent(Component $ui_component) : hasContent
99 {
100 $clone = clone($this);
101 $clone->content = $ui_component;
102
103 return $clone;
104 }
105
109 public function getContent() : Component
110 {
111 if ($this->content_wrapper !== null) {
112 $wrapper = $this->content_wrapper;
113
114 return $wrapper();
115 }
116
117 return $this->content;
118 }
119
124 {
125 // bugfix mantis 25526: make aria labels mandatory
126 if (($symbol instanceof Glyph\Glyph && $symbol->getAriaLabel() === "") ||
127 ($symbol instanceof Icon\Icon && $symbol->getLabel() === "")) {
128 throw new LogicException("the symbol's aria label MUST be set to ensure accessibility");
129 }
130
131 $clone = clone($this);
132 $clone->symbol = $symbol;
133
134 return $clone;
135 }
136
140 public function getSymbol() : Symbol
141 {
142 return $this->symbol;
143 }
144
148 public function hasSymbol() : bool
149 {
150 return ($this->symbol instanceof Symbol);
151 }
152
156 public function withTerminatedCallback(Closure $callback) : supportsTerminating
157 {
158 $clone = clone $this;
159 $clone->terminated_callback = $callback;
160
161 return $clone;
162 }
163
167 public function getTerminatedCallback() : ?Closure
168 {
170 }
171
175 public function hasTerminatedCallback() : bool
176 {
177 return $this->terminated_callback instanceof Closure;
178 }
179}
An exception for terminatinating execution or to throw for unit testing.
withTerminatedCallback(Closure $callback)
@inheritDoc
Definition: Tool.php:156
withSymbol(Symbol $symbol)
@inheritDoc
Definition: Tool.php:123
withContent(Component $ui_component)
@inheritDoc
Definition: Tool.php:98
withContentWrapper(Closure $content_wrapper)
@inheritDoc
Definition: Tool.php:87
Interface hasSymbol Methods for Entries with Symbols.
Definition: hasSymbol.php:33
A component is the most general form of an entity in the UI.
Definition: Component.php:14
This describes how a glyph could be modified during construction of UI.
Definition: Glyph.php:14
This describes how an icon could be modified during construction of UI.
Definition: Icon.php:10
This describes a symbol.
Definition: Symbol.php:12