19 declare(strict_types=1);
48 private readonly
string $id,
49 private readonly
UI $ui,
50 private readonly
User $user,
51 private readonly
Provide $legal_documents,
52 private readonly
Closure $render,
53 private readonly
Closure $build_user,
56 $this->create_input = $create_input ?? fn(
string $class, ...$args) =>
new $class(...$args);
61 return $this->
user->matchingDocument()->map($this->
guis(...))->except(fn() =>
new Ok([]))->value();
66 if ($this->
user->matchingDocument()->isError()) {
67 $this->
ui->loadLanguageModule($this->
id);
68 $this->
ui->loadLanguageModule(
'ldoc');
69 $this->
ui->mainTemplate()->setOnScreenMessage(
'failure', sprintf(
70 $this->
ui->txt(
'account_reg_not_possible'),
76 if ($input && !$form->
getInput($this->checkboxVariableName())) {
77 $input->setAlert($this->
ui->txt(
'force_accept_usr_agreement'));
87 $user = ($this->build_user)($user);
89 $user->acceptMatchingDocument();
91 $user->acceptAnyDocument();
98 $header->setTitle($this->
ui->txt(
'usr_agreement'));
101 $document_content = ($this->render)($this->legal_documents->document()->contentAsComponent($document->
content()));
102 $doc->setHtml(sprintf(
'<div id="%s_agreement">%s</div>', htmlentities($this->
id), $document_content));
105 $checkbox->setRequired(
true);
106 $checkbox->setValue(
'1');
108 return [$header, $doc, $checkbox];
A result encapsulates a value or an error and simplifies the handling of those.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Signals that a result contains no value.