ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
AbstractStorableResource.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
32{
37 protected array $stakeholders = [];
38 protected string $storage_id = '';
39 protected bool $confidential = false;
40
44 public function __construct(protected ResourceIdentification $identification)
45 {
46 $this->revisions = new RevisionCollection($this->identification);
47 }
48
50 {
51 return $this->identification;
52 }
53
54 public function getCurrentRevision(): Revision
55 {
56 return $this->revisions->getCurrent(false);
57 }
58
60 {
61 return $this->revisions->getCurrent(true);
62 }
63
64 public function getSpecificRevision(int $number): ?Revision
65 {
66 foreach ($this->getAllRevisionsIncludingDraft() as $revision) {
67 if ($revision->getVersionNumber() === $number) {
68 return $revision;
69 }
70 }
71 return null;
72 }
73
74 public function hasSpecificRevision(int $number): bool
75 {
76 foreach ($this->getAllRevisionsIncludingDraft() as $revision) {
77 if ($revision->getVersionNumber() === $number) {
78 return true;
79 }
80 }
81 return false;
82 }
83
87 public function getAllRevisions(): array
88 {
89 return $this->revisions->getAll(false);
90 }
91
95 public function getAllRevisionsIncludingDraft(): array
96 {
97 return $this->revisions->getAll(true);
98 }
99
100 public function addRevision(Revision $revision): void
101 {
102 $this->revisions->add($revision);
103 }
104
105 public function removeRevision(Revision $revision): void
106 {
107 $this->revisions->remove($revision);
108 }
109
110 public function replaceRevision(Revision $revision): void
111 {
112 $this->revisions->replaceSingleRevision($revision);
113 }
114
115 public function setRevisions(RevisionCollection $collection): void
116 {
117 $this->revisions = $collection;
118 }
119
123 public function getStakeholders(): array
124 {
125 return $this->stakeholders;
126 }
127
128 public function addStakeholder(ResourceStakeholder $s): void
129 {
130 $this->stakeholders[] = $s;
131 }
132
133 public function removeStakeholder(ResourceStakeholder $s): void
134 {
135 foreach ($this->stakeholders as $k => $stakeholder) {
136 if ($stakeholder->getId() === $s->getId()) {
137 unset($this->stakeholders[$k]);
138 }
139 }
140 }
141
145 public function setStakeholders(array $stakeholders): self
146 {
147 $this->stakeholders = $stakeholders;
148
149 return $this;
150 }
151
152 public function getStorageId(): string
153 {
154 return $this->storage_id;
155 }
156
157 public function setStorageId(string $storage_id): void
158 {
159 $this->storage_id = $storage_id;
160 }
161
166 public function getMaxRevision(bool $including_drafts = false): int
167 {
168 return $this->revisions->getMax($including_drafts);
169 }
170
171 public function getFullSize(): int
172 {
173 return $this->revisions->getFullSize();
174 }
175
176 abstract public function getType(): ResourceType;
177
178 public function isConfidential(): bool
179 {
180 return $this->confidential;
181 }
182
183 public function setConfidential(bool $confidential): void
184 {
185 $this->confidential = $confidential;
186 }
187}
isConfidential()
Confidential resources are redacted in the administration for everyone except the owner of the curren...
__construct(protected ResourceIdentification $identification)
StorableFileResource constructor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...