ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
ILIAS\LegalDocuments\Administration Class Reference
+ Collaboration diagram for ILIAS\LegalDocuments\Administration:

Public Member Functions

 __construct (private readonly Config $config, private readonly Container $container, private readonly UI $ui, ?Closure $confirmation=null, ?WrapperFactory $http_wrapper=null, ?Factory $refinery=null)
 
 deleteDocumentsConfirmation (string $form_link, string $submit_command, string $cancel_command, array $documents)
 
 deleteDocuments (array $documents)
 
 withDocumentAndCriterion (Closure $proc)
 
 retrieveDocuments ()
 
 retrieveIds ()
 
 idOrHash (object $gui, Closure $then)
 
 targetWithDoc (object $gui, Document $document, string $cmd, string $method='getLinkTarget')
 
 targetWithDocAndCriterion (object $gui, Document $document, Criterion $criterion, string $cmd, string $method='getLinkTarget')
 
 willLinkWith ($gui, array $parameters=[])
 
 withFormData (Form $form, Closure $then)
 
 find (Closure $predicate, array $array)
 A More...
 
 currentDocument ()
 
 criterionForm (string $url, Document $document, ?CriterionContent $criterion=null)
 
 requireDocumentHash ()
 
 tabs (array $tabs, array $run_after=[])
 
 uploadContent ()
 
 setContent ($component)
 
 addDocumentButton (string $add_document_link)
 
 setVariable (string $variable, $component)
 
 render ($component)
 
 resetBox (DateTimeImmutable $reset_date, array $buttons=[])
 
 resetButton (string $confirm_reset_link)
 
 documentForm (Closure $link, string $title, Closure $document_content, bool $may_be_new)
 
 saveDocumentOrder (array $documents, array $order_by_document)
 
 withDocumentsAndOrder (Closure $proc)
 A More...
 
 exitWithJsonResponse ($value)
 
 requireEditable ()
 
 externalSettingsMessage (bool $enabled)
 
 isInvalidHTML (string $string)
 
 isValidHTML (string $string)
 
 canReadUserAdministration ()
 

Private Member Functions

 retrieveValueOrDefaultFromPost (string $key, Transformation $transformation, mixed $default=null)
 
 retrieveValueOrDefaultFromQuery (string $key, Transformation $transformation, mixed $default=null)
 
 canWriteUserAdministration ()
 
 addTab (string $id, string $text, string $link, bool $can_access=true)
 

Private Attributes

readonly Closure $confirmation
 
WrapperFactory $http_wrapper
 
Factory $refinery
 

Detailed Description

Definition at line 52 of file Administration.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LegalDocuments\Administration::__construct ( private readonly Config  $config,
private readonly Container  $container,
private readonly UI  $ui,
?Closure  $confirmation = null,
?WrapperFactory  $http_wrapper = null,
?Factory  $refinery = null 
)
Parameters
null|Closure()Confirmation $confirmation

Definition at line 62 of file Administration.php.

References ILIAS\UI\examples\MessageBox\Confirmation\confirmation(), and ILIAS\Repository\refinery().

69  {
70  $this->confirmation = $confirmation ?? fn() => new Confirmation($this->container->language());
71  $this->http_wrapper = $http_wrapper ?? $this->container->http()->wrapper();
72  $this->refinery = $refinery ?? $this->container->refinery();
73  }
confirmation()
description: > Example for rendering a confirmation message box.
+ Here is the call graph for this function:

Member Function Documentation

◆ addDocumentButton()

ILIAS\LegalDocuments\Administration::addDocumentButton ( string  $add_document_link)

Definition at line 379 of file Administration.php.

References ILIAS\Repository\ui().

379  : Component
380  {
381  return $this->ui->create()->button()->primary(
382  $this->ui->txt('add_document_btn_label'),
383  $add_document_link
384  );
385  }
+ Here is the call graph for this function:

◆ addTab()

ILIAS\LegalDocuments\Administration::addTab ( string  $id,
string  $text,
string  $link,
bool  $can_access = true 
)
private

Definition at line 558 of file Administration.php.

Referenced by ILIAS\LegalDocuments\Administration\tabs().

558  : void
559  {
560  if ($can_access) {
561  $this->container->tabs()->addTab($id, $text, $link);
562  }
563  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ canReadUserAdministration()

ILIAS\LegalDocuments\Administration::canReadUserAdministration ( )

Definition at line 548 of file Administration.php.

References USER_FOLDER_ID.

548  : bool
549  {
550  return $this->container->rbac()->system()->checkAccess('read', USER_FOLDER_ID);
551  }
const USER_FOLDER_ID
Definition: constants.php:33

◆ canWriteUserAdministration()

ILIAS\LegalDocuments\Administration::canWriteUserAdministration ( )
private

Definition at line 553 of file Administration.php.

References USER_FOLDER_ID.

Referenced by ILIAS\LegalDocuments\Administration\externalSettingsMessage().

553  : bool
554  {
555  return $this->container->rbac()->system()->checkAccess('write', USER_FOLDER_ID);
556  }
const USER_FOLDER_ID
Definition: constants.php:33
+ Here is the caller graph for this function:

◆ criterionForm()

ILIAS\LegalDocuments\Administration::criterionForm ( string  $url,
Document  $document,
?CriterionContent  $criterion = null 
)

Definition at line 317 of file Administration.php.

References ILIAS\LegalDocuments\Value\Document\content(), ILIAS\Repository\ui(), and ILIAS\UI\Implementation\Component\Input\withValue().

317  : Form
318  {
319  $groups = $this->config->legalDocuments()->document()->conditionGroups($criterion);
320  $group = $this->ui->create()->input()->field()->switchableGroup($groups->choices(), $this->ui->txt('form_criterion'));
321  $value = $criterion ? $criterion->type() : $groups->defaultSelection();
322  if ($value) {
323  $group = $group->withValue($value);
324  }
325 
326  $title = $this->ui->create()->input()->field()->text($this->ui->txt('form_document'))->withValue($document->content()->title())->withDisabled(true);
327 
328  $section = $this->ui->create()->input()->field()->section([
329  $title,
330  'content' => $group,
331  ], $this->ui->txt($criterion ? 'form_edit_criterion_head' : 'form_attach_criterion_head'));
332 
333  return $this->ui->create()->input()->container()->form()->standard($url, [$section]);
334  }
$url
Definition: shib_logout.php:68
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
+ Here is the call graph for this function:

◆ currentDocument()

ILIAS\LegalDocuments\Administration::currentDocument ( )
Returns
Result<Document>

Definition at line 295 of file Administration.php.

References null, ILIAS\Repository\refinery(), and ILIAS\LegalDocuments\Administration\retrieveValueOrDefaultFromQuery().

Referenced by ILIAS\LegalDocuments\Administration\idOrHash(), and ILIAS\LegalDocuments\Administration\withDocumentAndCriterion().

295  : Result
296  {
297  $doc_id = $this->retrieveValueOrDefaultFromQuery(
298  'doc_id',
299  $this->refinery->kindlyTo()->int(),
300  );
301 
302  if (!$doc_id) {
303  //Try reading from UI-Table action
304  $doc_id = $this->retrieveValueOrDefaultFromQuery(
305  'legal_document_id',
306  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
307  []
308  );
309  $doc_id = current($doc_id) ?: null;
310  }
311 
312  $repo = $this->config->legalDocuments()->document()->repository();
313 
314  return $this->refinery->kindlyTo()->int()->applyTo(new Ok($doc_id))->then($repo->find(...));
315  }
retrieveValueOrDefaultFromQuery(string $key, Transformation $transformation, mixed $default=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteDocuments()

ILIAS\LegalDocuments\Administration::deleteDocuments ( array  $documents)
Parameters
list<Document>$documents

Definition at line 94 of file Administration.php.

94  : void
95  {
96  array_map(
97  $this->config->legalDocuments()->document()->repository()->deleteDocument(...),
98  $documents
99  );
100  }

◆ deleteDocumentsConfirmation()

ILIAS\LegalDocuments\Administration::deleteDocumentsConfirmation ( string  $form_link,
string  $submit_command,
string  $cancel_command,
array  $documents 
)
Parameters
list<Document>$documents

Definition at line 78 of file Administration.php.

References ILIAS\UI\examples\MessageBox\Confirmation\confirmation(), and ILIAS\Repository\ui().

78  : string
79  {
80  $items = array_column(array_map(fn($x) => [$x->id(), $x->content()->title()], $documents), 1, 0);
81 
82  return (($this->confirmation)())->render(
83  $form_link,
84  $submit_command,
85  $cancel_command,
86  $this->ui->txt('sure_delete_documents_p'),
87  $items
88  );
89  }
confirmation()
description: > Example for rendering a confirmation message box.
+ Here is the call graph for this function:

◆ documentForm()

ILIAS\LegalDocuments\Administration::documentForm ( Closure  $link,
string  $title,
Closure  $document_content,
bool  $may_be_new 
)
Parameters
Closure(string)string $link
Closure()Result<DocumentContent> $document_content

Definition at line 430 of file Administration.php.

References ILIAS\Repository\ui().

430  : Form
431  {
432  $edit_link = $link('editDocument');
433  $content_title = $may_be_new ? 'form_document' : 'form_document_new';
434 
435  $section = $this->ui->create()->input()->field()->section([
436  'title' => $this->ui->create()->input()->field()->text($this->ui->txt('title'))->withRequired(true)->withValue($title),
437  'content' => $this->ui->create()->input()->field()->file(new UploadHandler($link, $document_content, $this->ui->txt(...)), $this->ui->txt($content_title))->withAcceptedMimeTypes([
438  'text/html',
439  'text/plain',
440  ])->withRequired($may_be_new),
441  ], $this->ui->txt($may_be_new ? 'form_new_doc_head' : 'form_edit_doc_head'));
442 
443  return $this->ui->create()->input()->container()->form()->standard($edit_link, [$section]);
444  }
+ Here is the call graph for this function:

◆ exitWithJsonResponse()

ILIAS\LegalDocuments\Administration::exitWithJsonResponse (   $value)

Definition at line 501 of file Administration.php.

References ILIAS\Filesystem\Stream\Streams\ofString().

501  : void
502  {
503  // ... The content type cannot be set to application/json, because the components/ILIAS/UI/src/templates/js/Input/Field/file.js:392
504  // does not expect that the content type is correct and parses it again ...
505  $this->container->http()->saveResponse($this->container->http()->response()/* ->withHeader('Content-Type', 'application/json') */->withBody(
506  Streams::ofString(json_encode($value))
507  ));
508 
509  $this->container->http()->sendResponse();
510  $this->container->http()->close();
511  }
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

◆ externalSettingsMessage()

ILIAS\LegalDocuments\Administration::externalSettingsMessage ( bool  $enabled)

Definition at line 520 of file Administration.php.

References ILIAS\LegalDocuments\Administration\canWriteUserAdministration(), ILIAS\Repository\ui(), USER_FOLDER_ID, and ILIAS\LegalDocuments\Administration\willLinkWith().

520  : Component
521  {
522  $message_box = $this->ui->create()->messageBox()->info(
523  $this->ui->txt('withdrawal_usr_deletion') . ': ' . $this->ui->txt($enabled ? 'enabled' : 'disabled')
524  );
525 
526  if (!$this->canWriteUserAdministration()) {
527  return $message_box;
528  }
529 
530  return $message_box->withLinks([
531  $this->ui->create()->link()->standard(
532  $this->ui->txt('adm_external_setting_edit'),
533  $this->willLinkWith(ilObjUserFolderGUI::class, ['ref_id' => (string) USER_FOLDER_ID])('generalSettings')
534  )
535  ]);
536  }
const USER_FOLDER_ID
Definition: constants.php:33
willLinkWith($gui, array $parameters=[])
+ Here is the call graph for this function:

◆ find()

ILIAS\LegalDocuments\Administration::find ( Closure  $predicate,
array  $array 
)

A

Parameters
Closure(A)bool $predicate
list<A>$array
Returns
A|null

Definition at line 281 of file Administration.php.

References null.

Referenced by ILIAS\LegalDocuments\Administration\withDocumentAndCriterion().

282  {
283  foreach ($array as $value) {
284  if ($predicate($value)) {
285  return $value;
286  }
287  }
288 
289  return null;
290  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ idOrHash()

ILIAS\LegalDocuments\Administration::idOrHash ( object  $gui,
Closure  $then 
)
Parameters
Closure(Closure(string)string, string, DocumentId, bool): mixed $then

Definition at line 204 of file Administration.php.

References ILIAS\LegalDocuments\Administration\currentDocument(), ILIAS\LegalDocuments\Administration\requireDocumentHash(), and ILIAS\LegalDocuments\Administration\willLinkWith().

204  : void
205  {
206  $with_doc_id = fn($document) => $then($this->willLinkWith($gui, ['doc_id' => $document->id()]), $document->content()->title(), new NumberId($document), false);
207  $with_hash = fn(string $hash) => $then($this->willLinkWith($gui, ['hash' => $hash]), '', new HashId($hash), true);
208  $try_hash = fn() => new Ok($with_hash($this->requireDocumentHash()));
209 
210  $this->currentDocument()
211  ->map($with_doc_id)
212  ->except($try_hash)
213  ->value();
214 
215  }
willLinkWith($gui, array $parameters=[])
+ Here is the call graph for this function:

◆ isInvalidHTML()

ILIAS\LegalDocuments\Administration::isInvalidHTML ( string  $string)

Definition at line 538 of file Administration.php.

References ILIAS\LegalDocuments\Administration\isValidHTML().

538  : bool
539  {
540  return !$this->isValidHTML($string);
541  }
+ Here is the call graph for this function:

◆ isValidHTML()

ILIAS\LegalDocuments\Administration::isValidHTML ( string  $string)

Definition at line 543 of file Administration.php.

Referenced by ILIAS\LegalDocuments\Administration\isInvalidHTML().

543  : bool
544  {
545  return (new ValidHTML())->isTrue($string);
546  }
+ Here is the caller graph for this function:

◆ render()

ILIAS\LegalDocuments\Administration::render (   $component)
Parameters
list<Component>|Component|string$component

Definition at line 398 of file Administration.php.

Referenced by ILIAS\LegalDocuments\Administration\setContent(), and ILIAS\LegalDocuments\Administration\setVariable().

398  : string
399  {
400  if (is_string($component)) {
401  return $component;
402  }
403  return $this->container->ui()->renderer()->render($component);
404  }
+ Here is the caller graph for this function:

◆ requireDocumentHash()

ILIAS\LegalDocuments\Administration::requireDocumentHash ( )

Definition at line 336 of file Administration.php.

Referenced by ILIAS\LegalDocuments\Administration\idOrHash().

336  : string
337  {
338  return $this->container->http()->wrapper()->query()->retrieve('hash', $this->container->refinery()->to()->string());
339  }
+ Here is the caller graph for this function:

◆ requireEditable()

ILIAS\LegalDocuments\Administration::requireEditable ( )

Definition at line 513 of file Administration.php.

513  : void
514  {
515  if (!$this->config->editable()) {
516  $this->container['ilErr']->raiseError($this->container->language()->txt('permission_denied'), $this->container['ilErr']->WARNING);
517  }
518  }

◆ resetBox()

ILIAS\LegalDocuments\Administration::resetBox ( DateTimeImmutable  $reset_date,
array  $buttons = [] 
)
Parameters
array<Button>$buttons

Definition at line 409 of file Administration.php.

References ilDatePresentation\formatDate(), IL_CAL_UNIX, and ILIAS\Repository\ui().

409  : Component
410  {
411  $reset_date = new ilDateTime($reset_date->getTimeStamp(), IL_CAL_UNIX);
412  return $this->ui->create()
413  ->messageBox()
414  ->info(sprintf($this->ui->txt('last_reset_date'), ilDatePresentation::formatDate($reset_date)))
415  ->withButtons($buttons);
416  }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
+ Here is the call graph for this function:

◆ resetButton()

ILIAS\LegalDocuments\Administration::resetButton ( string  $confirm_reset_link)

Definition at line 418 of file Administration.php.

References ILIAS\Repository\ui().

418  : Button
419  {
420  return $this->ui->create()->button()->standard(
421  $this->ui->txt('reset_for_all_users'),
422  $confirm_reset_link
423  );
424  }
+ Here is the call graph for this function:

◆ retrieveDocuments()

ILIAS\LegalDocuments\Administration::retrieveDocuments ( )
Returns
list<Document>

Definition at line 128 of file Administration.php.

References ILIAS\LegalDocuments\Administration\retrieveIds().

128  : array
129  {
130  $ids = $this->retrieveIds();
131  $documents = $this->config->legalDocuments()->document()->repository()->select($ids);
132  if (count($documents) !== count($ids)) {
133  throw new InvalidArgumentException('List contains invalid documents.');
134  }
135 
136  return $documents;
137  }
+ Here is the call graph for this function:

◆ retrieveIds()

ILIAS\LegalDocuments\Administration::retrieveIds ( )
Returns
list<int>

Definition at line 142 of file Administration.php.

References ILIAS\Repository\refinery(), ILIAS\LegalDocuments\Administration\retrieveValueOrDefaultFromPost(), and ILIAS\LegalDocuments\Administration\retrieveValueOrDefaultFromQuery().

Referenced by ILIAS\LegalDocuments\Administration\retrieveDocuments().

142  : array
143  {
144  $ids = $this->retrieveValueOrDefaultFromPost(
145  'ids',
146  $this->container->refinery()->kindlyTo()->listOf(
147  $this->container->refinery()->kindlyTo()->int()
148  )
149  );
150 
151  if (!$ids) {
152  //Try reading from UI-Table action
153  $ids = $this->retrieveValueOrDefaultFromQuery(
154  'legal_document_id',
155  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
156  []
157  );
158  }
159 
160  if (!$ids) {
161  //Try reading from UI-Table "apply to all objects"
162  $ids = $this->retrieveValueOrDefaultFromQuery(
163  'legal_document_id',
164  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()),
165  []
166  );
167 
168  if (current($ids) === 'ALL_OBJECTS') {
169  $ids = [];
170  foreach ($this->config->legalDocuments()->document()->repository()->all() as $document) {
171  $ids[] = $document->id();
172  }
173  }
174  }
175 
176  return $ids ?: [];
177  }
retrieveValueOrDefaultFromQuery(string $key, Transformation $transformation, mixed $default=null)
retrieveValueOrDefaultFromPost(string $key, Transformation $transformation, mixed $default=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retrieveValueOrDefaultFromPost()

ILIAS\LegalDocuments\Administration::retrieveValueOrDefaultFromPost ( string  $key,
Transformation  $transformation,
mixed  $default = null 
)
private

Definition at line 179 of file Administration.php.

Referenced by ILIAS\LegalDocuments\Administration\retrieveIds().

179  : mixed
180  {
181  return $this->container->http()->wrapper()->post()->retrieve(
182  $key,
183  $this->container->refinery()->byTrying([
184  $transformation,
185  $this->container->refinery()->always($default)
186  ])
187  );
188  }
+ Here is the caller graph for this function:

◆ retrieveValueOrDefaultFromQuery()

ILIAS\LegalDocuments\Administration::retrieveValueOrDefaultFromQuery ( string  $key,
Transformation  $transformation,
mixed  $default = null 
)
private

Definition at line 190 of file Administration.php.

Referenced by ILIAS\LegalDocuments\Administration\currentDocument(), and ILIAS\LegalDocuments\Administration\retrieveIds().

190  : mixed
191  {
192  return $this->container->http()->wrapper()->query()->retrieve(
193  $key,
194  $this->container->refinery()->byTrying([
195  $transformation,
196  $this->container->refinery()->always($default)
197  ])
198  );
199  }
+ Here is the caller graph for this function:

◆ saveDocumentOrder()

ILIAS\LegalDocuments\Administration::saveDocumentOrder ( array  $documents,
array  $order_by_document 
)
Parameters
list<Document>$documents
array<int,int>$order_by_document

Definition at line 450 of file Administration.php.

450  : void
451  {
452  $update = $this->config->legalDocuments()->document()->repository()->updateDocumentOrder(...);
453 
454  usort($documents, fn($document, $other) => $order_by_document[$document->id()] - $order_by_document[$other->id()]);
455 
456  array_map(
457  fn($document, int $order) => $update(new NumberId($document), $order),
458  $documents,
459  range(10, 10 * count($documents), 10)
460  );
461  }

◆ setContent()

ILIAS\LegalDocuments\Administration::setContent (   $component)
Parameters
list<Component>|Component|string$component

Definition at line 374 of file Administration.php.

References ILIAS\LegalDocuments\Administration\render(), and ILIAS\Repository\ui().

374  : void
375  {
376  $this->ui->mainTemplate()->setContent($this->render($component));
377  }
+ Here is the call graph for this function:

◆ setVariable()

ILIAS\LegalDocuments\Administration::setVariable ( string  $variable,
  $component 
)
Parameters
list<Component>|Component$component

Definition at line 390 of file Administration.php.

References ILIAS\LegalDocuments\Administration\render(), and ILIAS\Repository\ui().

390  : void
391  {
392  $this->ui->mainTemplate()->setVariable($variable, $this->render($component));
393  }
+ Here is the call graph for this function:

◆ tabs()

ILIAS\LegalDocuments\Administration::tabs ( array  $tabs,
array  $run_after = [] 
)
Parameters
list<array{0string, 1: string, 2: string}> $tabs
array<string,Closure()void> $run_after

Definition at line 345 of file Administration.php.

References ILIAS\LegalDocuments\Administration\addTab().

345  : void
346  {
347  foreach ($tabs as $tab) {
348  $this->addTab(...$tab);
349  if (isset($run_after[$tab[0]])) {
350  $run_after[$tab[0]]();
351  }
352  }
353  }
addTab(string $id, string $text, string $link, bool $can_access=true)
+ Here is the call graph for this function:

◆ targetWithDoc()

ILIAS\LegalDocuments\Administration::targetWithDoc ( object  $gui,
Document  $document,
string  $cmd,
string  $method = 'getLinkTarget' 
)

Definition at line 217 of file Administration.php.

References ILIAS\LegalDocuments\Value\Document\id(), and ILIAS\LegalDocuments\Administration\willLinkWith().

217  : string
218  {
219  $link = $this->willLinkWith($gui, ['doc_id' => (string) $document->id()]);
220  return $link($cmd, $method);
221  }
willLinkWith($gui, array $parameters=[])
+ Here is the call graph for this function:

◆ targetWithDocAndCriterion()

ILIAS\LegalDocuments\Administration::targetWithDocAndCriterion ( object  $gui,
Document  $document,
Criterion  $criterion,
string  $cmd,
string  $method = 'getLinkTarget' 
)

Definition at line 223 of file Administration.php.

References ILIAS\LegalDocuments\Value\Criterion\id(), ILIAS\LegalDocuments\Value\Document\id(), and ILIAS\LegalDocuments\Administration\willLinkWith().

223  : string
224  {
225  $link = $this->willLinkWith($gui, [
226  'doc_id' => (string) $document->id(),
227  'criterion_id' => (string) $criterion->id(),
228  ]);
229 
230  return $link($cmd, $method);
231  }
willLinkWith($gui, array $parameters=[])
+ Here is the call graph for this function:

◆ uploadContent()

ILIAS\LegalDocuments\Administration::uploadContent ( )

Definition at line 355 of file Administration.php.

References null.

355  : string
356  {
357  $value = null;
358  $upload = $this->container->upload();
359  $upload->register(new PreProcessor(function (string $content) use (&$value): void {
360  $value = $content;
361  }));
362  $upload->process();
363  $result_array = $upload->getResults();
364  if (count($result_array) !== 1 || !current($result_array)->isOk()) {
365  throw new Exception('Unexpected upload result.');
366  }
367 
368  return $value;
369  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ willLinkWith()

ILIAS\LegalDocuments\Administration::willLinkWith (   $gui,
array  $parameters = [] 
)
Parameters
string | object$gui
array<int|string,string>$parameters
Returns
Closure(string, ?string?): string

Definition at line 238 of file Administration.php.

References null.

Referenced by ILIAS\LegalDocuments\Administration\externalSettingsMessage(), ILIAS\LegalDocuments\Administration\idOrHash(), ILIAS\LegalDocuments\Administration\targetWithDoc(), and ILIAS\LegalDocuments\Administration\targetWithDocAndCriterion().

238  : Closure
239  {
240  $class = is_string($gui) ? $gui : $gui::class;
241  return function (string $cmd, ?string $method = null) use ($gui, $class, $parameters): string {
242  $method ??= $class === $gui ? 'getLinkTargetByClass' : 'getLinkTarget';
243  $array = $this->container->ctrl()->getParameterArrayByClass($class);
244  foreach ($parameters as $key => $value) {
245  $this->container->ctrl()->setParameterByClass($class, (string) $key, $value);
246  }
247  $link = $this->container->ctrl()->$method($gui, $cmd);
248  foreach ($parameters as $key => $_) {
249  $this->container->ctrl()->setParameterByClass($class, (string) $key, $array[$key] ?? '');
250  }
251 
252  return $link;
253  };
254  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ withDocumentAndCriterion()

ILIAS\LegalDocuments\Administration::withDocumentAndCriterion ( Closure  $proc)
Parameters
Closure(Document,Criterion)void $proc

Definition at line 105 of file Administration.php.

References ILIAS\LegalDocuments\Administration\currentDocument(), ILIAS\LegalDocuments\Administration\find(), ILIAS\Repository\int(), and null.

105  : void
106  {
107  $document = $this->currentDocument()->value();
108  $criterion_id = ($this->container->http()->request()->getQueryParams()['criterion_id'] ?? null);
109  if (null === $criterion_id) {
110  throw new InvalidArgumentException('Missing query parameter criterion_id.');
111  }
112  $criterion_id = (int) $criterion_id;
113 
114  $criterion = $this->find(
115  fn($criterion) => $criterion->id() === $criterion_id,
116  $document->criteria()
117  );
118  if (!$criterion) {
119  throw new InvalidArgumentException('Invalid criterion_id given.');
120  }
121 
122  $proc($document, $criterion);
123  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
find(Closure $predicate, array $array)
A
+ Here is the call graph for this function:

◆ withDocumentsAndOrder()

ILIAS\LegalDocuments\Administration::withDocumentsAndOrder ( Closure  $proc)

A

Parameters
Closure(list<Document>,array<int,int>)A $proc
Returns
A

Definition at line 469 of file Administration.php.

470  {
471  // kindlyTo->int() does not accept numbers of the form "01".
472  $to_int = $this->container->refinery()->byTrying([
473  $this->container->refinery()->kindlyTo()->int(),
474  $this->container->refinery()->in()->series([
475  $this->container->refinery()->to()->string(),
476  $this->container->refinery()->custom()->transformation(fn($s) => ltrim($s, '0') ?: '0'),
477  $this->container->refinery()->kindlyTo()->int(),
478  ]),
479  ]);
480 
481  $order = $this->container->http()->request()->getParsedBody();
482  if (!is_array($order)) {
483  throw new InvalidArgumentException('Invalid order given. List of numbers expected.');
484  }
485 
486  $order = array_map($to_int, $order);
487  $document_ids = array_map($to_int, array_keys($order));
488  $order = array_combine($document_ids, array_values($order));
489 
490  $documents = $this->config->legalDocuments()->document()->repository()->all();
491 
492  foreach ($documents as $document) {
493  if (!isset($order[$document->id()])) {
494  $order[$document->id()] = $document->meta()->sorting();
495  }
496  }
497 
498  return $proc($documents, $order);
499  }

◆ withFormData()

ILIAS\LegalDocuments\Administration::withFormData ( Form  $form,
Closure  $then 
)
Parameters
Closure(array)void $then

Definition at line 259 of file Administration.php.

References $data, ILIAS\UI\Component\Input\Container\Container\getData(), null, and ILIAS\UI\Component\Input\Container\Container\withRequest().

259  : Form
260  {
261  $request = $this->container->http()->request();
262  if ($request->getMethod() !== 'POST') {
263  return $form;
264  }
265  $form = $form->withRequest($request);
266  $data = $form->getData();
267 
268  if ($data !== null) {
269  $then($data);
270  }
271 
272  return $form;
273  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

Field Documentation

◆ $confirmation

readonly Closure ILIAS\LegalDocuments\Administration::$confirmation
private

Definition at line 55 of file Administration.php.

◆ $http_wrapper

WrapperFactory ILIAS\LegalDocuments\Administration::$http_wrapper
private

Definition at line 56 of file Administration.php.

◆ $refinery

Factory ILIAS\LegalDocuments\Administration::$refinery
private

Definition at line 57 of file Administration.php.


The documentation for this class was generated from the following file: