108 $this->signal_generator = $signal_generator;
117 return $this->entries;
128 MainControls\Slate\Slate::class
133 if (array_key_exists($id, $this->entries)) {
134 throw new \InvalidArgumentException(
"The id of this entry is already taken.", 1);
137 $clone = clone $this;
138 $clone->entries[$id] = $entry;
147 return $this->tool_entries;
156 bool $initially_hidden =
false,
159 if (!$this->tools_button) {
160 throw new \LogicException(
"There must be a tool-button configured to add tool-entries", 1);
163 if (array_key_exists($id, $this->tool_entries)) {
164 throw new \InvalidArgumentException(
"The id of this entry is already taken.", 1);
167 $clone = clone $this;
168 $clone->tool_entries[$id] = $entry;
169 $signal = $this->signal_generator->create();
170 $signal->addOption(
'entry_id', $id);
171 $signal->addOption(
'action', self::ENTRY_ACTION_TRIGGER_MAPPED);
172 $clone->tool_signals[$id] = $signal;
174 if ($initially_hidden) {
175 $clone->initially_hidden_ids[] = $id;
179 $clone->close_buttons[$id] = $close_button;
189 $clone = clone $this;
190 $clone->tools_button = $button;
199 return $this->tools_button;
207 return $this->entry_click_signal;
215 return $this->tools_click_signal;
223 return $this->tools_removal_signal;
231 return $this->disengage_all_signal;
239 return $this->toggle_tools_signal;
247 $this->entry_click_signal = $this->signal_generator->create();
248 $this->tools_click_signal = $this->signal_generator->create();
249 $this->tools_removal_signal = $this->signal_generator->create();
250 $this->disengage_all_signal = $this->signal_generator->create();
251 $this->disengage_all_signal->addOption(
'action', self::ENTRY_ACTION_DISENGAGE_ALL);
252 $this->toggle_tools_signal = $this->signal_generator->create();
253 $this->toggle_tools_signal->addOption(
'action', self::ENTRY_ACTION_TOGGLE_TOOLS);
258 $clone = clone $this;
259 $clone->initSignals();
260 foreach (array_keys($this->tool_entries) as $tool_id) {
261 $this->tool_signals[$tool_id] = $this->signal_generator->create();
271 return $this->active;
279 $valid_entries = array_merge(
280 array_keys($this->entries),
281 array_keys($this->tool_entries),
284 if (!in_array($active, $valid_entries)) {
285 throw new \InvalidArgumentException(
"Invalid entry to activate: $active", 1);
288 $clone = clone $this;
289 $clone->active = $active;
298 return array_unique($this->initially_hidden_ids);
306 return $this->tool_signals[$tool_id];
314 return $this->close_buttons;
320 $clone = clone $this;
321 $clone->entries = [];
322 $clone->tool_entries = [];
330 if (!in_array($action, [self::ENTRY_ACTION_TRIGGER, self::ENTRY_ACTION_REMOVE])) {
331 throw new \InvalidArgumentException(
"invalid action for mainbar entry: $action", 1);
333 $signal = $this->signal_generator->create();
334 $signal->addOption(
'entry_id', $entry_id);
335 $signal->addOption(
'action', $action);
341 $clone = clone $this;
342 $clone->mainbar_tree_position = $tree_pos;
348 $clone = clone $this;
351 foreach ($clone->getEntries() as $k => $v) {
352 $clone->entries[$k] =
$f($counter, $v,
false);
357 foreach ($clone->getToolEntries() as $k => $v) {
358 $clone->tool_entries[$k] =
$f($counter, $v,
true);
const ENTRY_ACTION_TRIGGER
This describes the MainBar.
__construct(SignalGeneratorInterface $signal_generator)
withAdditionalToolEntry(string $id, Slate $entry, bool $initially_hidden=false, Button\Close $close_button=null)
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
withAdditionalEntry(string $id, $entry)
const ENTRY_ACTION_TOGGLE_TOOLS
trait ComponentHelper
Provides common functionality for component implementations.
initSignals()
Set the signals for this component.
const ENTRY_ACTION_REMOVE
withMappedSubNodes(callable $f)
getInitiallyHiddenToolIds()
const ENTRY_ACTION_TRIGGER_MAPPED
getEngageToolSignal(string $tool_id)
withMainBarTreePosition(string $tree_pos)
withActive(string $active)
getTriggerSignal(string $entry_id, string $action)
const ENTRY_ACTION_DISENGAGE_ALL
withToolsButton(Button\Bulky $button)
checkArgListElements($which, array &$values, $classes)
Check every element of the list if it is an instance of one of the given classes. ...