ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ReadOnlyDocumentRepository.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 use Exception;
29 
31 {
33  private const WHITELIST = [
34  'all',
35  'countAll',
36  'select',
37  'find',
38  'findId',
39  'documentFromRow',
40  'documentTable',
41  'exists',
42  ];
43 
44  public function __construct(private readonly DocumentRepository $repository)
45  {
46  }
47 
51  public function all(int $offset = 0, ?int $limit = null): array
52  {
53  $this->checkAccess(__FUNCTION__);
54  return $this->repository->all();
55  }
56 
57  public function countAll(): int
58  {
59  $this->checkAccess(__FUNCTION__);
60  return $this->repository->countAll();
61  }
62 
67  public function select(array $ids): array
68  {
69  $this->checkAccess(__FUNCTION__);
70  return $this->repository->select($ids);
71  }
72 
76  public function find(int $id): Result
77  {
78  $this->checkAccess(__FUNCTION__);
79  return $this->repository->find($id);
80  }
81 
85  public function findId(DocumentId $document_id): Result
86  {
87  $this->checkAccess(__FUNCTION__);
88  return $this->repository->findId($document_id);
89  }
90 
91  public function createDocument(string $title, DocumentContent $content): void
92  {
93  $this->checkAccess(__FUNCTION__);
94  $this->repository->createDocument($title, $content);
95  }
96 
97  public function createCriterion(Document $document, CriterionContent $content): void
98  {
99  $this->checkAccess(__FUNCTION__);
100  $this->repository->createCriterion($document, $content);
101  }
102 
103  public function deleteDocument(Document $document): void
104  {
105  $this->checkAccess(__FUNCTION__);
106  $this->repository->deleteDocument($document);
107  }
108 
109  public function deleteCriterion(int $criterion_id): void
110  {
111  $this->checkAccess(__FUNCTION__);
112  $this->repository->deleteCriterion($criterion_id);
113  }
114 
115  public function updateDocumentTitle(DocumentId $document_id, string $title): void
116  {
117  $this->checkAccess(__FUNCTION__);
118  $this->repository->updateDocumentTitle($document_id, $title);
119  }
120 
121  public function updateDocumentContent(DocumentId $document_id, DocumentContent $content): void
122  {
123  $this->checkAccess(__FUNCTION__);
124  $this->repository->updateDocumentContent($document_id, $content);
125  }
126 
127  public function updateDocumentOrder(DocumentId $document_id, int $order): void
128  {
129  $this->checkAccess(__FUNCTION__);
130  $this->repository->updateDocumentOrder($document_id, $order);
131  }
132 
133  public function updateCriterionContent(int $criterion_id, CriterionContent $content): void
134  {
135  $this->checkAccess(__FUNCTION__);
136  $this->repository->updateCriterionContent($criterion_id, $content);
137  }
138 
139  public function documentFromRow(array $row, array $criteria): Document
140  {
141  $this->checkAccess(__FUNCTION__);
142  return $this->repository->documentFromRow($row, $criteria);
143  }
144 
145  public function documentTable(): string
146  {
147  $this->checkAccess(__FUNCTION__);
148  return $this->repository->documentTable();
149  }
150 
151  public function exists(string $doc_id_name): string
152  {
153  $this->checkAccess(__FUNCTION__);
154  return $this->repository->exists($doc_id_name);
155  }
156 
157  private function checkAccess(string $method): void
158  {
159  if (!in_array($method, self::WHITELIST, true)) {
160  throw new Exception('You are not allowed to call this method.');
161  }
162  }
163 }
createCriterion(Document $document, CriterionContent $content)
repository()
description: > Example for rendering a repository card
Definition: repository.php:33
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
updateCriterionContent(int $criterion_id, CriterionContent $content)
__construct(private readonly DocumentRepository $repository)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
updateDocumentContent(DocumentId $document_id, DocumentContent $content)