ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
StorableFileResource.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
4 
9 
15 {
16 
20  private $identification;
24  private $revisions = [];
28  private $stakeholders = [];
32  private $storage_id = '';
33 
39  {
40  $this->identification = $identification;
41  $this->revisions = new RevisionCollection($identification);
42  }
43 
48  {
49  return $this->identification;
50  }
51 
55  public function getCurrentRevision() : Revision
56  {
57  return $this->revisions->getCurrent();
58  }
59 
63  public function getSpecificRevision(int $number) : ?Revision
64  {
65  foreach ($this->getAllRevisions() as $revision) {
66  if ($revision->getVersionNumber() === $number) {
67  return $revision;
68  }
69  }
70  return null;
71  }
72 
76  public function hasSpecificRevision(int $number) : bool
77  {
78  foreach ($this->getAllRevisions() as $revision) {
79  if ($revision->getVersionNumber() === $number) {
80  return true;
81  }
82  }
83  return false;
84  }
85 
89  public function getAllRevisions() : array
90  {
91  return $this->revisions->getAll();
92  }
93 
97  public function addRevision(Revision $revision) : void
98  {
99  $this->revisions->add($revision);
100  }
101 
102  public function removeRevision(Revision $revision) : void
103  {
104  $this->revisions->remove($revision);
105  }
106 
110  public function replaceRevision(Revision $revision) : void
111  {
112  $this->revisions->replaceSingleRevision($revision);
113  }
114 
118  public function setRevisions(RevisionCollection $collection) : void
119  {
120  $this->revisions = $collection;
121  }
122 
126  public function getStakeholders() : array
127  {
128  return $this->stakeholders;
129  }
130 
134  public function addStakeholder(ResourceStakeholder $s) : void
135  {
136  $this->stakeholders[] = $s;
137  }
138 
142  public function removeStakeholder(ResourceStakeholder $s) : void
143  {
144  foreach ($this->stakeholders as $k => $stakeholder) {
145  if ($stakeholder->getId() === $s->getId()) {
146  unset($this->stakeholders[$k]);
147  }
148  }
149  }
150 
156  {
157  $this->stakeholders = $stakeholders;
158 
159  return $this;
160  }
161 
165  public function getStorageId() : string
166  {
167  return $this->storage_id;
168  }
169 
173  public function setStorageId(string $storage_id) : void
174  {
175  $this->storage_id = $storage_id;
176  }
177 
181  public function getMaxRevision() : int
182  {
183  return $this->revisions->getMax();
184  }
185 
186 }
__construct(ResourceIdentification $identification)
StorableFileResource constructor.