103 $this->signal_generator = $signal_generator;
112 return $this->entries;
123 MainControls\Slate\Slate::class
128 if (array_key_exists($id, $this->entries)) {
129 throw new \InvalidArgumentException(
"The id of this entry is already taken.", 1);
132 $clone = clone $this;
133 $clone->entries[$id] = $entry;
142 return $this->tool_entries;
151 bool $initially_hidden =
false,
154 if (!$this->tools_button) {
155 throw new \LogicException(
"There must be a tool-button configured to add tool-entries", 1);
158 if (array_key_exists($id, $this->tool_entries)) {
159 throw new \InvalidArgumentException(
"The id of this entry is already taken.", 1);
162 $clone = clone $this;
163 $clone->tool_entries[$id] = $entry;
164 $signal = $this->signal_generator->create();
165 $signal->addOption(
'entry_id', $id);
166 $signal->addOption(
'action', self::ENTRY_ACTION_TRIGGER_MAPPED);
167 $clone->tool_signals[$id] = $signal;
169 if ($initially_hidden) {
170 $clone->initially_hidden_ids[] = $id;
174 $clone->close_buttons[$id] = $close_button;
184 $clone = clone $this;
185 $clone->tools_button = $button;
194 return $this->tools_button;
202 $clone = clone $this;
203 $clone->more_button = $button;
212 return $this->more_button;
220 return $this->entry_click_signal;
228 return $this->tools_click_signal;
236 return $this->tools_removal_signal;
244 return $this->disengage_all_signal;
252 return $this->toggle_tools_signal;
260 $this->entry_click_signal = $this->signal_generator->create();
261 $this->tools_click_signal = $this->signal_generator->create();
262 $this->tools_removal_signal = $this->signal_generator->create();
263 $this->disengage_all_signal = $this->signal_generator->create();
264 $this->disengage_all_signal->addOption(
'action', self::ENTRY_ACTION_DISENGAGE_ALL);
265 $this->toggle_tools_signal = $this->signal_generator->create();
266 $this->toggle_tools_signal->addOption(
'action', self::ENTRY_ACTION_TOGGLE_TOOLS);
271 $clone = clone $this;
272 $clone->initSignals();
273 foreach (array_keys($this->tool_entries) as $tool_id) {
274 $this->tool_signals[$tool_id] = $this->signal_generator->create();
284 return $this->active;
292 $valid_entries = array_merge(
293 array_keys($this->entries),
294 array_keys($this->tool_entries),
297 if (!in_array($active, $valid_entries)) {
298 throw new \InvalidArgumentException(
"Invalid entry to activate: $active", 1);
301 $clone = clone $this;
302 $clone->active = $active;
311 return array_unique($this->initially_hidden_ids);
319 return $this->tool_signals[$tool_id];
327 return $this->close_buttons;
333 $clone = clone $this;
334 $clone->entries = [];
335 $clone->tool_entries = [];
343 if (!in_array($action, [self::ENTRY_ACTION_TRIGGER, self::ENTRY_ACTION_REMOVE])) {
346 $signal = $this->signal_generator->create();
347 $signal->addOption(
'entry_id', $entry_id);
348 $signal->addOption(
'action', $action);
354 $clone = clone $this;
355 $clone->mainbar_tree_position = $tree_pos;
361 $clone = clone $this;
364 foreach ($clone->getEntries() as $k => $v) {
365 $clone->entries[$k] =
$f($counter, $v,
false);
370 foreach ($clone->getToolEntries() as $k => $v) {
371 $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
withMoreButton(Button\Bulky $button)
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. ...