ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ProvideHistory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
34use ilObjUser;
35use Closure;
36
38{
40 private readonly Closure $create_table_gui;
41
45 public function __construct(
46 private readonly string $id,
47 private readonly HistoryRepository $repository,
48 private readonly ProvideDocument $document,
49 private readonly Container $container,
50 ?Closure $create_table_gui = null
51 ) {
52 $this->create_table_gui = $create_table_gui ?? fn($gui, $command, $t) => new Table($gui, $command, $t);
53 }
54
55 public function table(object $gui, string $command, string $reset_command, string $auto_complete_command): Component
56 {
57 $auto_complete_link = $this->container->ctrl()->getLinkTarget($gui, $auto_complete_command, '', true);
58 $ui = new UI($this->id, $this->container->ui(), $this->container->language());
59 $modal = new DocumentModal($this->container->ui(), $this->document->contentAsComponent(...));
60 $create = fn(string $class, ...$args) => $class === ilObjUser::class && !ilObjUser::_lookupLogin($args[0]) ?
61 null :
62 new $class(...$args);
63
64 $table = ($this->create_table_gui)($gui, $command, new HistoryTable(
65 $this->repository,
66 $this->document,
67 $reset_command,
68 $auto_complete_link,
69 $ui,
70 $modal,
71 $create
72 ));
73
74 return $this->container->ui()->factory()->legacy()->content($table->getHTML());
75 }
76
77 public function acceptDocument(ilObjUser $user, Document $document): void
78 {
79 $this->repository->acceptDocument($user, $document);
80 }
81
82 public function alreadyAccepted(ilObjUser $user, Document $document): bool
83 {
84 return $this->repository->alreadyAccepted($user, $document);
85 }
86
90 public function acceptedVersion(ilObjUser $user): Result
91 {
92 return $this->repository->acceptedVersion($user);
93 }
94
99 {
100 return $this->repository->currentDocumentOfAcceptedVersion($user);
101 }
102}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
alreadyAccepted(ilObjUser $user, Document $document)
acceptDocument(ilObjUser $user, Document $document)
table(object $gui, string $command, string $reset_command, string $auto_complete_command)
__construct(private readonly string $id, private readonly HistoryRepository $repository, private readonly ProvideDocument $document, private readonly Container $container, ?Closure $create_table_gui=null)
User class.
static _lookupLogin(int $a_user_id)
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:29
A component is the most general form of an entity in the UI.
Definition: Component.php:28
$container
@noRector
Definition: wac.php:37