ILIAS  release_8 Revision v8.24
Slate.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
28use ILIAS\UI\Implementation\Component\ComponentHelper;
30use ILIAS\UI\Implementation\Component\ReplaceSignal as ReplaceSignalImplementation;
32
33abstract class Slate implements ISlate\Slate
34{
35 use ComponentHelper;
37 use Triggerer;
38
39 // allowed ARIA roles
40 public const MENU = 'menu';
41
45 protected static array $allowed_aria_roles = array(
46 self::MENU
47 );
48
49 protected string $name;
50 protected Symbol $symbol;
53 protected ?Signal $replace_signal = null;
54 protected bool $engaged = false;
55 protected ?string $mainbar_tree_position = null;
56 protected ?string $aria_role = null;
58
62 public function __construct(
64 string $name,
66 ) {
67 $this->signal_generator = $signal_generator;
68 $this->name = $name;
69 $this->symbol = $symbol;
70
71 $this->initSignals();
72 }
73
77 protected function initSignals(): void
78 {
79 $this->toggle_signal = $this->signal_generator->create();
80 $this->engage_signal = $this->signal_generator->create();
81 $signal = $this->signal_generator->create(ReplaceSignalImplementation::class);
82 $this->replace_signal = $signal;
83 }
84
88 public function getName(): string
89 {
90 return $this->name;
91 }
92
96 public function getSymbol(): Symbol
97 {
98 return $this->symbol;
99 }
100
104 public function getToggleSignal(): Signal
105 {
107 }
108
112 public function getEngageSignal(): Signal
113 {
115 }
116
120 public function withEngaged(bool $state): ISlate\Slate
121 {
122 $clone = clone $this;
123 $clone->engaged = $state;
124 return $clone;
125 }
126
130 public function getEngaged(): bool
131 {
132 return $this->engaged;
133 }
134
138 abstract public function getContents(): array;
139
143 public function getReplaceSignal(): ?Signal
144 {
146 }
147
151 public function appendOnInView(Signal $signal): ISlate\Slate
152 {
153 return $this->appendTriggeredSignal($signal, 'in_view');
154 }
155
156
157 abstract public function withMappedSubNodes(callable $f): ISlate\Slate;
158
162 public function withMainBarTreePosition(string $tree_pos): ISlate\Slate
163 {
164 $clone = clone $this;
165 $clone->mainbar_tree_position = $tree_pos;
166 return $clone;
167 }
168
169 public function getMainBarTreePosition(): ?string
170 {
172 }
173
174 public function getMainBarTreeDepth(): int
175 {
176 $pos = explode(':', $this->mainbar_tree_position);
177 return count($pos) - 1;
178 }
179
183 public function withAriaRole(string $aria_role): ISlate\Slate
184 {
185 $this->checkArgIsElement(
186 "role",
188 self::$allowed_aria_roles,
189 implode('/', self::$allowed_aria_roles)
190 );
191 $clone = clone $this;
192 $clone->aria_role = $aria_role;
193 return $clone;
194 }
195
199 public function getAriaRole(): ?string
200 {
201 return $this->aria_role;
202 }
203}
__construct(SignalGeneratorInterface $signal_generator, string $name, Symbol $symbol)
Definition: Slate.php:62
getAriaRole()
Get the ARIA role on the slate.
Definition: Slate.php:199
initSignals()
Set the signals for this component.
Definition: Slate.php:77
withAriaRole(string $aria_role)
Get a slate like this, but with an additional ARIA role.
Definition: Slate.php:183
This signal replaces a component by ajax.
This describes a symbol.
Definition: Symbol.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Combined.php:20
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Combined.php:21
appendTriggeredSignal(C\Signal $signal, string $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:47
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.