ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Slate.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28use ILIAS\UI\Implementation\Component\ComponentHelper;
30use ILIAS\UI\Implementation\Component\ReplaceSignal as ReplaceSignalImplementation;
33
34abstract class Slate implements ISlate\Slate
35{
36 use ComponentHelper;
38 use Triggerer;
39 use HasHelpTopics;
40
41 // allowed ARIA roles
42 public const MENU = 'menu';
43
47 protected static array $allowed_aria_roles = array(
48 self::MENU
49 );
50
51 protected string $name;
52 protected Symbol $symbol;
55 protected ?Signal $replace_signal = null;
56 protected bool $engaged = false;
57 protected ?string $mainbar_tree_position = null;
58 protected ?string $aria_role = null;
60
64 public function __construct(
66 string $name,
68 ) {
69 $this->signal_generator = $signal_generator;
70 $this->name = $name;
71 $this->symbol = $symbol;
72
73 $this->initSignals();
74 }
75
79 protected function initSignals(): void
80 {
81 $this->toggle_signal = $this->signal_generator->create();
82 $this->engage_signal = $this->signal_generator->create();
83 $signal = $this->signal_generator->create(ReplaceSignalImplementation::class);
84 $this->replace_signal = $signal;
85 }
86
90 public function getName(): string
91 {
92 return $this->name;
93 }
94
98 public function getSymbol(): Symbol
99 {
100 return $this->symbol;
101 }
102
106 public function getToggleSignal(): Signal
107 {
109 }
110
114 public function getEngageSignal(): Signal
115 {
117 }
118
122 public function withEngaged(bool $state): ISlate\Slate
123 {
124 $clone = clone $this;
125 $clone->engaged = $state;
126 return $clone;
127 }
128
132 public function getEngaged(): bool
133 {
134 return $this->engaged;
135 }
136
140 abstract public function getContents(): array;
141
145 public function getReplaceSignal(): ?Signal
146 {
148 }
149
153 public function appendOnInView(Signal $signal): ISlate\Slate
154 {
155 return $this->appendTriggeredSignal($signal, 'in_view');
156 }
157
158
159 abstract public function withMappedSubNodes(callable $f): ISlate\Slate;
160
164 public function withMainBarTreePosition(string $tree_pos): ISlate\Slate
165 {
166 $clone = clone $this;
167 $clone->mainbar_tree_position = $tree_pos;
168 return $clone;
169 }
170
171 public function getMainBarTreePosition(): ?string
172 {
174 }
175
176 public function getMainBarTreeDepth(): int
177 {
178 $pos = explode(':', $this->mainbar_tree_position);
179 return count($pos) - 1;
180 }
181
185 public function withAriaRole(string $aria_role): ISlate\Slate
186 {
187 $this->checkArgIsElement(
188 "role",
190 self::$allowed_aria_roles,
191 implode('/', self::$allowed_aria_roles)
192 );
193 $clone = clone $this;
194 $clone->aria_role = $aria_role;
195 return $clone;
196 }
197
201 public function getAriaRole(): ?string
202 {
203 return $this->aria_role;
204 }
205}
__construct(SignalGeneratorInterface $signal_generator, string $name, Symbol $symbol)
Definition: Slate.php:64
getAriaRole()
Get the ARIA role on the slate.
Definition: Slate.php:201
initSignals()
Set the signals for this component.
Definition: Slate.php:79
withAriaRole(string $aria_role)
Get a slate like this, but with an additional ARIA role.
Definition: Slate.php:185
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: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.