19 declare(strict_types=1);
50 $this->
map = $map ??
new Map();
55 return $this->
addTo(
'after-login', Closure::fromCallable($after_login));
60 return $this->
addTo(
'footer', $this->slot->id(), Closure::fromCallable($show));
67 return $this->
addTo(
'withdraw', $this->slot->id(), $withdraw)
75 return $this->
addTo(
'show-on-login-page', $this->slot->id(), Closure::fromCallable($show));
80 $wiring = $this->
addTo(
'public-page', $this->slot->id(), fn(...$args) =>
new Ok($public_page(...$args)));
81 return null === $goto_name ?
83 $wiring->addTo(
'goto',
new ConditionalGotoLink($goto_name, fn() =>
new Target(ilStartUpGUI::class,
'showLegalDocuments', [
'id' => $this->slot->id()])));
88 $public_target =
new Target(ilStartUpGUI::class,
'showLegalDocuments', [
'id' => $this->slot->id()]);
89 $agreement_target =
new Target($this->
path(ilLegalDocumentsAgreementGUI::class),
'', [
'id' => $this->slot->id()]);
91 $wiring = $this->
addTo(
'public-page', $this->slot->id(), fn(...$args) =>
new Ok($on_login->
showAgreement(...$args)))
95 return null === $goto_name ?
102 $document = $this->
map->value()[
'document'][$this->slot->id()] ?? $this->
error(
'Cannot have a history without documents.');
103 return $this->
addTo(
'history', $this->slot->id(), $this->slot->history($document));
108 return $this->
addTo(
'self-registration', $self_registration);
113 return $this->
addTo(
'filter-online-users', $only_visible_users);
118 return $this->
addTo(
'constrain-internal-mail', $constraint);
123 return $this->
addTo(
'use-soap-api', $constraint);
129 $repository = $this->slot->documentRepository();
130 $document = $this->slot->document($this->slot->readOnlyDocuments($repository), $available_conditions, $content_as_component);
132 return $this->
addTo(
'document', $this->slot->id(), $document)
133 ->
addTo(
'writable-document', $this->slot->id(), $this->slot->document($repository, $available_conditions, $content_as_component));
138 return $this->
addTo(
'user-management-fields', $this->slot->id(), $field_value);
143 return $this->
addTo(
'public-api', $this->slot->id(), $api);
156 private function addTo(
string $name, $id_or_value, $value =
null): self
159 if ($value !==
null) {
160 if ($this->
map->has($name, $id_or_value)) {
161 throw new Exception(
'Duplicated entry. Key ' . $id_or_value .
' already exists for ' . $name);
163 $map = $map->set($name, $id_or_value, $value);
165 $map = $map->add($name, $id_or_value);
168 return new self($this->slot,
$map);
181 return static fn(...$args):
Result => $protector() ?
new Ok($to_be_protected(...$args)) :
new Error(
'Not available.');
187 private function path(
string $class): array
189 return [ilDashboardGUI::class, ilPersonalProfileGUI::class, $class];
canWithdraw(WithdrawProcess $withdraw_process)
__construct(private readonly SlotConstructor $slot, ?Map $map=null)
onSelfRegistration(SelfRegistration $self_registration)
canUseSoapApi(Constraint $constraint)
addTo(string $name, $id_or_value, $value=null)
protect(Closure $to_be_protected, Closure $protector)
A B
hasOnlineStatusFilter(callable $only_visible_users)
showAgreement(string $gui, string $cmd)
hasPublicApi(PublicApi $api)
A constraint encodes some resrtictions on values.
showInFooter(callable $show)
afterLogin(callable $after_login)
hasDocuments(array $content_as_component=[], ?SelectionMap $available_conditions=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
showWithdraw(string $gui, string $cmd)
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)