19 declare(strict_types=1);
59 return $this->
addTo(
'after-login', Closure::fromCallable($after_login));
64 return $this->
addTo(
'footer', $this->slot->id(), Closure::fromCallable($show));
71 return $this->
addTo(
'withdraw', $this->slot->id(), $withdraw)
80 return $this->
addTo(
'show-on-login-page', $this->slot->id(), Closure::fromCallable($show));
83 public function hasPublicPage(callable $public_page, ?
string $goto_name = null): self
85 $wiring = $this->
addTo(
'public-page', $this->slot->id(), fn(...$args) =>
new Ok($public_page(...$args)));
86 return null === $goto_name ?
88 $wiring->addTo(
'goto',
new ConditionalGotoLink($goto_name, fn() =>
new Target(ilStartUpGUI::class,
'showLegalDocuments', [
'id' => $this->slot->id()])));
93 $public_target =
new Target(ilStartUpGUI::class,
'showLegalDocuments', [
'id' => $this->slot->id()]);
94 $agreement_target =
new Target($this->
path(ilLegalDocumentsAgreementGUI::class),
'', [
'id' => $this->slot->id()]);
96 $wiring = $this->
addTo(
'public-page', $this->slot->id(), fn(...$args) =>
new Ok($on_login->
showAgreement(...$args)))
100 return null === $goto_name ?
107 $document = $this->
map->value()[
'document'][$this->slot->id()] ?? $this->
error(
'Cannot have a history without documents.');
108 return $this->
addTo(
'history', $this->slot->id(), $this->slot->history($document));
113 return $this->
addTo(
'self-registration', $self_registration);
118 return $this->
addTo(
'filter-online-users', $only_visible_users);
123 return $this->
addTo(
'constrain-internal-mail', $constraint);
128 return $this->
addTo(
'use-soap-api', $constraint);
133 $available_conditions = $available_conditions ??
new SelectionMap();
134 $repository = $this->slot->documentRepository();
135 $document = $this->slot->document($this->slot->readOnlyDocuments($repository), $available_conditions, $content_as_component);
137 return $this->
addTo(
'document', $this->slot->id(), $document)
138 ->
addTo(
'writable-document', $this->slot->id(), $this->slot->document($repository, $available_conditions, $content_as_component));
143 return $this->
addTo(
'user-management-fields', $this->slot->id(), $field_value);
148 return $this->
addTo(
'public-api', $this->slot->id(), $api);
161 private function addTo(
string $name, $id_or_value, $value = null)
164 if ($value !== null) {
165 if ($this->
map->has($name, $id_or_value)) {
166 throw new Exception(
'Duplicated entry. Key ' . $id_or_value .
' already exists for ' . $name);
168 $map = $map->set($name, $id_or_value, $value);
170 $map = $map->add($name, $id_or_value);
173 return new self($this->slot,
$map);
183 return static fn(...$args):
Result => $protector() ?
new Ok($to_be_protected(...$args)) :
new Error(
'Not available.');
186 private function path(
string $class): array
188 return [ilDashboardGUI::class, ilPersonalProfileGUI::class, $class];
canWithdraw(WithdrawProcess $withdraw_process)
onSelfRegistration(SelfRegistration $self_registration)
canUseSoapApi(Constraint $constraint)
addTo(string $name, $id_or_value, $value=null)
protect(Closure $to_be_protected, Closure $protector)
hasOnlineStatusFilter(callable $only_visible_users)
showAgreement(string $gui, string $cmd)
hasPublicApi(PublicApi $api)
A result encapsulates a value or an error and simplifies the handling of those.
A constraint encodes some resrtictions on values.
showInFooter(callable $show)
afterLogin(callable $after_login)
hasDocuments(array $content_as_component=[], ?SelectionMap $available_conditions=null)
showWithdraw(string $gui, string $cmd)
__construct(private readonly SlotConstructor $slot, Map $map=null)
A result encapsulates a value or an error and simplifies the handling of those.
hasUserManagementFields(callable $field_value)
showValidatePasswordMessage()
canReadInternalMails(Constraint $constraint)
showAgreementForm(string $gui, string $cmd)
showOnLoginPage(callable $show)
hasAgreement(Agreement $on_login, ?string $goto_name=null)
hasPublicPage(callable $public_page, ?string $goto_name=null)