1 <?php declare(strict_types=1);
40 $this->resource_builder =
$b;
41 $this->preloader = $l;
47 string $revision_title = null
49 if ($result->
isOK()) {
54 $revision_title ?? $result->
getName()
57 $resource = $this->resource_builder->new(
61 $resource->addStakeholder($stakeholder);
62 $this->resource_builder->store($resource);
64 return $resource->getIdentification();
66 throw new \LogicException(
"Can't handle UploadResult: " . $result->
getStatus()->getMessage());
72 string $revision_title = null
79 $revision_title ?? $stream->getMetadata()[
'uri']
82 $resource = $this->resource_builder->newFromStream(
87 $resource->addStakeholder($stakeholder);
88 $this->resource_builder->store($resource);
90 return $resource->getIdentification();
97 if ($this->resource_builder->has($resource_identification)) {
98 return $resource_identification;
108 $this->preloader->preload([$i->
serialize()]);
109 return $this->resource_builder->get($i);
114 $this->resource_builder->remove($this->resource_builder->get($identification), $stakeholder);
119 $resource = $this->resource_builder->clone($this->resource_builder->get($identification));
121 return $resource->getIdentification();
130 string $revision_title = null
132 if ($result->
isOK()) {
133 if (!$this->resource_builder->has($identification)) {
134 throw new \LogicException(
"Resource not found, can't append new version in: " . $identification->
serialize());
136 $resource = $this->resource_builder->get($identification);
139 $resource->getMaxRevision() + 1,
141 $revision_title ?? $result->
getName()
144 $this->resource_builder->append(
149 $resource->addStakeholder($stakeholder);
151 $this->resource_builder->store($resource);
153 return $resource->getCurrentRevision();
155 throw new \LogicException(
"Can't handle UploadResult: " . $result->
getStatus()->getMessage());
162 string $revision_title = null
164 if ($result->
isOK()) {
165 if (!$this->resource_builder->has($identification)) {
166 throw new \LogicException(
"Resource not found, can't append new version in: " . $identification->
serialize());
168 $resource = $this->resource_builder->get($identification);
171 $resource->getMaxRevision() + 1,
173 $revision_title ?? $result->
getName()
175 $this->resource_builder->replaceWithUpload(
180 $resource->addStakeholder($stakeholder);
182 $this->resource_builder->store($resource);
184 return $resource->getCurrentRevision();
186 throw new \LogicException(
"Can't handle UploadResult: " . $result->
getStatus()->getMessage());
193 string $revision_title = null
195 if (!$this->resource_builder->has($identification)) {
196 throw new \LogicException(
"Resource not found, can't append new version in: " . $identification->
serialize());
199 $resource = $this->resource_builder->get($identification);
202 $resource->getMaxRevision() + 1,
204 $revision_title ?? $stream->getMetadata()[
'uri']
207 $this->resource_builder->appendFromStream(
213 $resource->addStakeholder($stakeholder);
215 $this->resource_builder->store($resource);
217 return $resource->getCurrentRevision();
224 string $revision_title = null
226 if (!$this->resource_builder->has($identification)) {
227 throw new \LogicException(
"Resource not found, can't append new version in: " . $identification->
serialize());
230 $resource = $this->resource_builder->get($identification);
233 $resource->getMaxRevision() + 1,
235 $revision_title ?? $stream->getMetadata()[
'uri']
238 $this->resource_builder->replaceWithStream(
244 $resource->addStakeholder($stakeholder);
246 $this->resource_builder->store($resource);
248 return $resource->getCurrentRevision();
253 return $this->resource_builder->get($identification)->getCurrentRevision();
258 $this->resource_builder->storeRevision($revision);
265 $resource = $this->resource_builder->get($identification);
266 $this->resource_builder->appendFromRevision($resource, $revision_number);
267 $this->resource_builder->store($resource);
274 $resource = $this->resource_builder->get($identification);
275 $this->resource_builder->removeRevision($resource, $revision_number);
276 $this->resource_builder->store($resource);
upload(UploadResult $result, ResourceStakeholder $stakeholder, string $revision_title=null)
__construct(ResourceBuilder $b, RepositoryPreloader $l)
Manager constructor.
Interface StorageResource.
find(string $identification)
Interface Identification.
replaceWithUpload(ResourceIdentification $identification, UploadResult $result, ResourceStakeholder $stakeholder, string $revision_title=null)
appendNewRevisionFromStream(ResourceIdentification $identification, FileStream $stream, ResourceStakeholder $stakeholder, string $revision_title=null)
rollbackRevision(ResourceIdentification $identification, int $revision_number)
getResource(ResourceIdentification $i)
updateRevision(Revision $revision)
appendNewRevision(ResourceIdentification $identification, UploadResult $result, ResourceStakeholder $stakeholder, string $revision_title=null)
clone(ResourceIdentification $identification)
Interface ResourceStakeholder.
getCurrentRevision(ResourceIdentification $identification)
replaceWithStream(ResourceIdentification $identification, FileStream $stream, ResourceStakeholder $stakeholder, string $revision_title=null)
removeRevision(ResourceIdentification $identification, int $revision_number)
Interface RepositoryPreloader.
Interface FileStream The base interface for all filesystem streams.
stream(FileStream $stream, ResourceStakeholder $stakeholder, string $revision_title=null)