ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
Slate.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2018 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
14use ILIAS\UI\Implementation\Component\ReplaceSignal as ReplaceSignalImplementation;
16
20abstract class Slate implements ISlate\Slate
21{
24 use Triggerer;
25
26 // allowed ARIA roles
27 const MENU = 'menu';
28
32 protected $name;
33
37 protected $symbol;
38
42 protected $toggle_signal;
43
47 protected $engage_signal;
48
52 protected $replace_signal;
53
57 protected $engaged = false;
58
63
67 protected $aria_role;
68
72 protected static $allowed_aria_roles = array(
73 self::MENU
74 );
75
80 public function __construct(
81 SignalGeneratorInterface $signal_generator,
82 string $name,
84 ) {
85 $this->signal_generator = $signal_generator;
86 $this->name = $name;
87 $this->symbol = $symbol;
88
89 $this->initSignals();
90 }
91
95 protected function initSignals()
96 {
97 $this->toggle_signal = $this->signal_generator->create();
98 $this->engage_signal = $this->signal_generator->create();
99 $this->replace_signal = $this->signal_generator->create(ReplaceSignalImplementation::class);
100 }
101
105 public function getName() : string
106 {
107 return $this->name;
108 }
109
113 public function getSymbol() : Symbol
114 {
115 return $this->symbol;
116 }
117
121 public function getToggleSignal() : Signal
122 {
124 }
125
129 public function getEngageSignal() : Signal
130 {
132 }
133
137 public function withEngaged(bool $state) : ISlate\Slate
138 {
139 $clone = clone $this;
140 $clone->engaged = $state;
141 return $clone;
142 }
143
147 public function getEngaged() : bool
148 {
149 return $this->engaged;
150 }
151
155 abstract public function getContents() : array;
156
160 public function getReplaceSignal() : ReplaceSignal
161 {
163 }
164
168 public function appendOnInView(Signal $signal) : \ILIAS\UI\Component\MainControls\Slate\Slate
169 {
170 return $this->appendTriggeredSignal($signal, 'in_view');
171 }
172
173 public function appendOnFirstView(Signal $signal) : \ILIAS\UI\Component\MainControls\Slate\Slate
174 {
175 return $this->appendTriggeredSignal($signal, 'on_first_view');
176 }
177
178
179 abstract public function withMappedSubNodes(callable $f);
180
184 public function withMainBarTreePosition(string $tree_pos)
185 {
186 $clone = clone $this;
187 $clone->mainbar_tree_position = $tree_pos;
188 return $clone;
189 }
190
194 public function getMainBarTreePosition()
195 {
197 }
198
199 public function getMainBarTreeDepth()
200 {
201 $pos = explode(':', $this->mainbar_tree_position);
202 return count($pos) - 1;
203 }
204
211 public function withAriaRole(string $aria_role) : Slate
212 {
213 $this->checkArgIsElement(
214 "role",
215 $aria_role,
216 self::$allowed_aria_roles,
217 implode('/', self::$allowed_aria_roles)
218 );
219 $clone = clone $this;
220 $clone->aria_role = $aria_role;
221 return $clone;
222 }
223
229 public function getAriaRole() : ?string
230 {
231 return $this->aria_role;
232 }
233}
An exception for terminatinating execution or to throw for unit testing.
__construct(SignalGeneratorInterface $signal_generator, string $name, Symbol $symbol)
Definition: Slate.php:80
getAriaRole()
Get the ARIA role on the slate.
Definition: Slate.php:229
initSignals()
Set the signals for this component.
Definition: Slate.php:95
withAriaRole(string $aria_role)
Get a slate like this, but with an additional ARIA role.
Definition: Slate.php:211
A component is the most general form of an entity in the UI.
Definition: Component.php:14
This signal replaces a component by ajax.
This describes a symbol.
Definition: Symbol.php:12
appendTriggeredSignal(Component\Signal $signal, $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:31
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
trait ComponentHelper
Provides common functionality for component implementations.
checkArgIsElement($which, $value, $array, $name)
Throw an InvalidArgumentException if $value is not an element of array.
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.