ILIAS  release_8 Revision v8.24
StorableFileResource.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
33{
34 private \ILIAS\ResourceStorage\Revision\RevisionCollection $revisions;
38 private array $stakeholders = [];
39 private string $storage_id = '';
41
46 {
47 $this->identification = $identification;
48 $this->revisions = new RevisionCollection($identification);
49 }
50
55 {
57 }
58
62 public function getCurrentRevision(): Revision
63 {
64 return $this->revisions->getCurrent();
65 }
66
70 public function getSpecificRevision(int $number): ?Revision
71 {
72 foreach ($this->getAllRevisions() as $revision) {
73 if ($revision->getVersionNumber() === $number) {
74 return $revision;
75 }
76 }
77 return null;
78 }
79
83 public function hasSpecificRevision(int $number): bool
84 {
85 foreach ($this->getAllRevisions() as $revision) {
86 if ($revision->getVersionNumber() === $number) {
87 return true;
88 }
89 }
90 return false;
91 }
92
96 public function getAllRevisions(): array
97 {
98 return $this->revisions->getAll();
99 }
100
104 public function addRevision(Revision $revision): void
105 {
106 $this->revisions->add($revision);
107 }
108
109 public function removeRevision(Revision $revision): void
110 {
111 $this->revisions->remove($revision);
112 }
113
117 public function replaceRevision(Revision $revision): void
118 {
119 $this->revisions->replaceSingleRevision($revision);
120 }
121
125 public function setRevisions(RevisionCollection $collection): void
126 {
127 $this->revisions = $collection;
128 }
129
133 public function getStakeholders(): array
134 {
135 return $this->stakeholders;
136 }
137
141 public function addStakeholder(ResourceStakeholder $s): void
142 {
143 $this->stakeholders[] = $s;
144 }
145
149 public function removeStakeholder(ResourceStakeholder $s): void
150 {
151 foreach ($this->stakeholders as $k => $stakeholder) {
152 if ($stakeholder->getId() === $s->getId()) {
153 unset($this->stakeholders[$k]);
154 }
155 }
156 }
157
161 public function setStakeholders(array $stakeholders): self
162 {
163 $this->stakeholders = $stakeholders;
164
165 return $this;
166 }
167
171 public function getStorageId(): string
172 {
173 return $this->storage_id;
174 }
175
179 public function setStorageId(string $storage_id): void
180 {
181 $this->storage_id = $storage_id;
182 }
183
187 public function getMaxRevision(): int
188 {
189 return $this->revisions->getMax();
190 }
191}
__construct(ResourceIdentification $identification)
StorableFileResource constructor.
ILIAS ResourceStorage Revision RevisionCollection $revisions
setRevisions(RevisionCollection $collection)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...