ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Provide.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\LegalDocuments;
22 
23 use Exception;
30 
31 class Provide
32 {
33  public function __construct(
34  private readonly string $id,
35  private readonly Internal $internal,
36  private readonly Container $container,
37  private readonly string $document_key = 'document'
38  ) {
39  }
40 
41  public function withdrawal(): ProvideWithdrawal
42  {
43  if (null === $this->internal->get('withdraw', $this->id)) {
44  throw new Exception('No withdrawal process defined for: ' . $this->id);
45  }
46  return new ProvideWithdrawal($this->id, $this->container->ctrl(), $this->container['ilAuthSession']);
47  }
48 
49  public function publicPage(): ProvidePublicPage
50  {
51  if (null === $this->internal->get('public-page', $this->id)) {
52  throw new Exception('No agreement defined for: ' . $this->id);
53  }
54  return new ProvidePublicPage($this->id, $this->container->ctrl());
55  }
56 
57  public function document(): ProvideDocument
58  {
59  return $this->internal->get($this->document_key, $this->id) ?? $this->error('No documents defined for: ' . $this->id);
60  }
61 
62  public function history(): ProvideHistory
63  {
64  return $this->internal->get('history', $this->id) ?? $this->error('No history defined for: ' . $this->id);
65  }
66 
67  public function allowEditing(): self
68  {
69  return new self($this->id, $this->internal, $this->container, 'writable-document');
70  }
71 
72  public function publicApi(): ?PublicApi
73  {
74  return $this->internal->get('public-api', $this->id);
75  }
76 
77  public function id(): string
78  {
79  return $this->id;
80  }
81 
82  private function error(string $message): void
83  {
84  throw new Exception($message);
85  }
86 }
__construct(private readonly string $id, private readonly Internal $internal, private readonly Container $container, private readonly string $document_key='document')
Definition: Provide.php:33
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
$container
Definition: wac.php:36
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
error(string $message)
Definition: Provide.php:82
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$message
Definition: xapiexit.php:31