ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Sortation.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\UI\Implementation\Component\ComponentHelper;
29
31{
32 use ComponentHelper;
34 use Triggerer;
35
37 protected ?string $label_prefix = null;
38 protected ?string $target_url = null;
39 protected string $parameter_name = "sortation";
40 protected ?string $active = null;
41
45 public function __construct(
46 protected array $options,
47 protected string $selected,
48 protected SignalGeneratorInterface $signal_generator
49 ) {
50 $check = array_keys($options);
51 $check[] = '';
52 $this->checkArgIsElement('selected', $selected, $check, 'one of [' . implode(', ', array_keys($options)) . ']');
53 $this->initSignals();
54 }
55
59 public function withResetSignals(): self
60 {
61 $clone = clone $this;
62 $clone->initSignals();
63 return $clone;
64 }
65
69 protected function initSignals(): void
70 {
71 $this->select_signal = $this->signal_generator->create();
72 }
73
77 public function withLabelPrefix(string $label_prefix): self
78 {
79 $clone = clone $this;
80 $clone->label_prefix = $label_prefix;
81 return $clone;
82 }
83
84 public function getLabelPrefix(): ?string
85 {
87 }
88
92 public function withTargetURL(string $url, string $parameter_name): self
93 {
94 $this->checkStringArg("url", $url);
95 $this->checkStringArg("parameter_name", $parameter_name);
96 $clone = clone $this;
97 $clone->target_url = $url;
98 $clone->parameter_name = $parameter_name;
99 return $clone;
100 }
101
105 public function getTargetURL(): ?string
106 {
107 return $this->target_url;
108 }
109
113 public function getParameterName(): string
114 {
116 }
117
121 public function getOptions(): array
122 {
123 return $this->options;
124 }
125
129 public function withOnSort(Signal $signal): self
130 {
131 return $this->withTriggeredSignal($signal, 'sort');
132 }
133
137 public function getSelectSignal(): Signal
138 {
140 }
141
142 public function withSelected(string $selected_option): self
143 {
144 $possible = array_keys($this->options);
145 $this->checkArgIsElement('selected_option', $selected_option, $possible, 'one of [' . implode(', ', $possible) . ']');
146 $clone = clone $this;
147 $clone->selected = $selected_option;
148 return $clone;
149 }
150
151 public function getSelected(): ?string
152 {
153 return $this->selected;
154 }
155}
$check
Definition: buildRTE.php:81
initSignals()
Set the signals for this component.
Definition: Sortation.php:69
withTargetURL(string $url, string $parameter_name)
Definition: Sortation.php:92
__construct(protected array $options, protected string $selected, protected SignalGeneratorInterface $signal_generator)
Definition: Sortation.php:45
withTriggeredSignal(C\Signal $signal, string $event)
Add a triggered signal, replacing any other signals registered on the same event.
Definition: Triggerer.php:62
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
$url
Definition: shib_logout.php:68