ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ProvideHistory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
33 use ilObjUser;
34 use Closure;
35 
37 {
39  private readonly Closure $create_table_gui;
40 
44  public function __construct(
45  private readonly string $id,
46  private readonly HistoryRepository $repository,
47  private readonly ProvideDocument $document,
48  private readonly Container $container,
49  ?Closure $create_table_gui = null
50  ) {
51  $this->create_table_gui = $create_table_gui ?? fn($gui, $command, $t) => new Table($gui, $command, $t);
52  }
53 
54  public function table(object $gui, string $command, string $reset_command, string $auto_complete_command): Component
55  {
56  $auto_complete_link = $this->container->ctrl()->getLinkTarget($gui, $auto_complete_command, '', true);
57  $ui = new UI($this->id, $this->container->ui(), $this->container->language());
58  $modal = new DocumentModal($this->container->ui(), $this->document->contentAsComponent(...));
59  $create = fn(string $class, ...$args) => $class === ilObjUser::class && !ilObjUser::_lookupLogin($args[0], 'login') ?
60  null :
61  new $class(...$args);
62 
63  $table = ($this->create_table_gui)($gui, $command, new HistoryTable(
64  $this->repository,
65  $this->document,
66  $reset_command,
67  $auto_complete_link,
68  $ui,
69  $modal,
70  $create
71  ));
72 
73  return $this->container->ui()->factory()->legacy($table->getHTML());
74  }
75 
76  public function acceptDocument(ilObjUser $user, Document $document): void
77  {
78  $this->repository->acceptDocument($user, $document);
79  }
80 
81  public function alreadyAccepted(ilObjUser $user, Document $document): bool
82  {
83  return $this->repository->alreadyAccepted($user, $document);
84  }
85 
89  public function acceptedVersion(ilObjUser $user): Result
90  {
91  return $this->repository->acceptedVersion($user);
92  }
93 
98  {
99  return $this->repository->currentDocumentOfAcceptedVersion($user);
100  }
101 }
acceptDocument(ilObjUser $user, Document $document)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:14
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
$container
Definition: wac.php:14
__construct(private readonly string $id, private readonly HistoryRepository $repository, private readonly ProvideDocument $document, private readonly Container $container, ?Closure $create_table_gui=null)
alreadyAccepted(ilObjUser $user, Document $document)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
table(object $gui, string $command, string $reset_command, string $auto_complete_command)
static _lookupLogin(int $a_user_id)