ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
43 public function __construct(protected ResourceIdentification $identification)
44 {
45 $this->revisions = new RevisionCollection($this->identification);
46 }
47
49 {
50 return $this->identification;
51 }
52
53 public function getCurrentRevision(): Revision
54 {
55 return $this->revisions->getCurrent(false);
56 }
57
59 {
60 return $this->revisions->getCurrent(true);
61 }
62
63 public function getSpecificRevision(int $number): ?Revision
64 {
65 foreach ($this->getAllRevisionsIncludingDraft() as $revision) {
66 if ($revision->getVersionNumber() === $number) {
67 return $revision;
68 }
69 }
70 return null;
71 }
72
73 public function hasSpecificRevision(int $number): bool
74 {
75 foreach ($this->getAllRevisionsIncludingDraft() as $revision) {
76 if ($revision->getVersionNumber() === $number) {
77 return true;
78 }
79 }
80 return false;
81 }
82
86 public function getAllRevisions(): array
87 {
88 return $this->revisions->getAll(false);
89 }
90
94 public function getAllRevisionsIncludingDraft(): array
95 {
96 return $this->revisions->getAll(true);
97 }
98
99 public function addRevision(Revision $revision): void
100 {
101 $this->revisions->add($revision);
102 }
103
104 public function removeRevision(Revision $revision): void
105 {
106 $this->revisions->remove($revision);
107 }
108
109 public function replaceRevision(Revision $revision): void
110 {
111 $this->revisions->replaceSingleRevision($revision);
112 }
113
114 public function setRevisions(RevisionCollection $collection): void
115 {
116 $this->revisions = $collection;
117 }
118
122 public function getStakeholders(): array
123 {
124 return $this->stakeholders;
125 }
126
127 public function addStakeholder(ResourceStakeholder $s): void
128 {
129 $this->stakeholders[] = $s;
130 }
131
132 public function removeStakeholder(ResourceStakeholder $s): void
133 {
134 foreach ($this->stakeholders as $k => $stakeholder) {
135 if ($stakeholder->getId() === $s->getId()) {
136 unset($this->stakeholders[$k]);
137 }
138 }
139 }
140
144 public function setStakeholders(array $stakeholders): self
145 {
146 $this->stakeholders = $stakeholders;
147
148 return $this;
149 }
150
151 public function getStorageId(): string
152 {
153 return $this->storage_id;
154 }
155
156 public function setStorageId(string $storage_id): void
157 {
158 $this->storage_id = $storage_id;
159 }
160
165 public function getMaxRevision(bool $including_drafts = false): int
166 {
167 return $this->revisions->getMax($including_drafts);
168 }
169
170 public function getFullSize(): int
171 {
172 return $this->revisions->getFullSize();
173 }
174
175 abstract public function getType(): ResourceType;
176}
__construct(protected ResourceIdentification $identification)
StorableFileResource constructor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...