ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ResourceBuilder.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
45 
52 {
53  use SecureString;
54 
58  private \ILIAS\ResourceStorage\Information\Repository\InformationRepository $information_repository;
62  private \ILIAS\ResourceStorage\Resource\Repository\ResourceRepository $resource_repository;
66  private \ILIAS\ResourceStorage\Revision\Repository\RevisionRepository $revision_repository;
70  private \ILIAS\ResourceStorage\Stakeholder\Repository\StakeholderRepository $stakeholder_repository;
71 
75  protected array $resource_cache = [];
76  protected \ILIAS\ResourceStorage\Policy\FileNamePolicy $file_name_policy;
77  protected \ILIAS\ResourceStorage\StorageHandler\StorageHandler $primary_storage_handler;
81  private bool $auto_migrate = true;
82 
87  public function __construct(
88  StorageHandlerFactory $storage_handler_factory,
89  Repositories $repositories,
90  LockHandler $lock_handler,
91  StreamAccess $stream_access,
92  FileNamePolicy $file_name_policy = null
93  ) {
94  $this->storage_handler_factory = $storage_handler_factory;
95  $this->lock_handler = $lock_handler;
96  $this->stream_access = $stream_access;
97  $this->primary_storage_handler = $storage_handler_factory->getPrimary();
98  $this->revision_repository = $repositories->getRevisionRepository();
99  $this->resource_repository = $repositories->getResourceRepository();
100  $this->information_repository = $repositories->getInformationRepository();
101  $this->stakeholder_repository = $repositories->getStakeholderRepository();
102  $this->file_name_policy = $file_name_policy ?? new NoneFileNamePolicy();
103  }
104 
105  //
106  // Methods to create new Resources (from an Upload, a Stream od just a blank one)
107  //
108 
112  public function new(
113  UploadResult $result,
114  InfoResolver $info_resolver,
115  ResourceType $type = ResourceType::SINGLE_FILE
116  ): StorableResource {
117  $resource = $this->resource_repository->blank(
118  $this->primary_storage_handler->getIdentificationGenerator()->getUniqueResourceIdentification(),
119  $type
120  );
121 
122  return $this->append($resource, $result, $info_resolver, RevisionStatus::PUBLISHED);
123  }
124 
125  public function newFromStream(
126  FileStream $stream,
127  InfoResolver $info_resolver,
128  bool $keep_original = false,
129  ResourceType $type = ResourceType::SINGLE_FILE
130  ): StorableResource {
131  $resource = $this->resource_repository->blank(
132  $this->primary_storage_handler->getIdentificationGenerator()->getUniqueResourceIdentification(),
133  $type
134  );
135 
136  return $this->appendFromStream(
137  $resource,
138  $stream,
139  $info_resolver,
140  RevisionStatus::PUBLISHED,
141  $keep_original
142  );
143  }
144 
145  public function newBlank(ResourceType $type = ResourceType::SINGLE_FILE): StorableResource
146  {
147  $resource = $this->resource_repository->blank(
148  $this->primary_storage_handler->getIdentificationGenerator()->getUniqueResourceIdentification(),
149  $type
150  );
151  $resource->setStorageID($this->primary_storage_handler->getID());
152 
153  return $resource;
154  }
155 
156  //
157  // Methods to append something to an existing resource
158  //
159 
160  public function append(
161  StorableResource $resource,
162  UploadResult $result,
163  InfoResolver $info_resolver,
164  RevisionStatus $status
165  ): StorableResource {
166  if (
167  $status !== RevisionStatus::DRAFT
168  && $resource->getCurrentRevisionIncludingDraft()->getStatus() === RevisionStatus::DRAFT) {
169  throw new \LogicException(
170  'You can not replace a draft revision with a published, you must publish the current revision first'
171  );
172  }
173 
174  $new_revision = $this->revision_repository->blankFromUpload($info_resolver, $resource, $result, $status);
175 
176  if ($resource->getCurrentRevisionIncludingDraft()->getStatus() === RevisionStatus::DRAFT) {
177  $clone_revision = $this->buildDraftReplacementRevision($resource, $new_revision, $info_resolver);
178  $resource->replaceRevision($clone_revision);
179  } else {
180  $new_revision = $this->populateRevisionInfo($new_revision, $info_resolver);
181  $resource->addRevision($new_revision);
182  }
183 
184  $resource->setStorageID(
185  $resource->getStorageID() === '' ? $this->primary_storage_handler->getID() : $resource->getStorageID()
186  );
187 
188  return $resource;
189  }
190 
194  public function replaceWithUpload(
195  StorableResource $resource,
196  UploadResult $result,
197  InfoResolver $info_resolver
198  ): StorableResource {
199  if ($resource->getCurrentRevisionIncludingDraft()->getStatus() === RevisionStatus::DRAFT) {
200  throw new \LogicException('You can not replace a draft revision, you must publish it first');
201  }
202  $revision = $this->revision_repository->blankFromUpload(
203  $info_resolver,
204  $resource,
205  $result,
206  RevisionStatus::PUBLISHED
207  );
208  $revision = $this->populateRevisionInfo($revision, $info_resolver);
209 
210  foreach ($resource->getAllRevisionsIncludingDraft() as $existing_revision) {
211  $this->deleteRevision($resource, $existing_revision);
212  }
213 
214  $resource->addRevision($revision);
215  $resource->setStorageID(
216  $resource->getStorageID() === '' ? $this->primary_storage_handler->getID() : $resource->getStorageID()
217  );
218 
219  return $resource;
220  }
221 
222  public function appendFromStream(
223  StorableResource $resource,
224  FileStream $stream,
225  InfoResolver $info_resolver,
226  RevisionStatus $status,
227  bool $keep_original = false,
228  ): StorableResource {
229  if (
230  $status !== RevisionStatus::DRAFT
231  && $resource->getCurrentRevisionIncludingDraft()->getStatus() === RevisionStatus::DRAFT) {
232  throw new \LogicException(
233  'You can not replace a draft revision with a published, you must publish the current revision first'
234  );
235  }
236 
237  $new_revision = $this->revision_repository->blankFromStream(
238  $info_resolver,
239  $resource,
240  $stream,
241  $status,
242  $keep_original
243  );
244 
245  if ($resource->getCurrentRevisionIncludingDraft()->getStatus() === RevisionStatus::DRAFT) {
246  $clone_revision = $this->buildDraftReplacementRevision($resource, $new_revision, $info_resolver);
247  $resource->replaceRevision($clone_revision);
248  } else {
249  $new_revision = $this->populateRevisionInfo($new_revision, $info_resolver);
250  $resource->addRevision($new_revision);
251  }
252 
253  $resource->setStorageID(
254  $resource->getStorageID() === '' ? $this->primary_storage_handler->getID() : $resource->getStorageID()
255  );
256 
257  return $resource;
258  }
259 
260  public function replaceWithStream(
261  StorableResource $resource,
262  FileStream $stream,
263  InfoResolver $info_resolver,
264  bool $keep_original = false,
265  ): StorableResource {
266  if ($resource->getCurrentRevisionIncludingDraft()->getStatus() === RevisionStatus::DRAFT) {
267  throw new \LogicException('You can not replace a draft revision, you must publish it first');
268  }
269  $revision = $this->revision_repository->blankFromStream(
270  $info_resolver,
271  $resource,
272  $stream,
273  RevisionStatus::PUBLISHED,
274  $keep_original
275  );
276  $revision = $this->populateRevisionInfo($revision, $info_resolver);
277 
278  foreach ($resource->getAllRevisionsIncludingDraft() as $existing_revision) {
279  $this->deleteRevision($resource, $existing_revision);
280  }
281 
282  $resource->addRevision($revision);
283  $resource->setStorageID(
284  $resource->getStorageID() === '' ? $this->primary_storage_handler->getID() : $resource->getStorageID()
285  );
286 
287  return $resource;
288  }
289 
290  public function appendFromRevision(
291  StorableResource $resource,
292  int $revision_number
293  ): StorableResource {
294  if ($resource->getCurrentRevisionIncludingDraft()->getStatus() === RevisionStatus::DRAFT) {
295  throw new \LogicException('You can not replace a draft revision, you must publish it first');
296  }
297  $existing_revision = $resource->getSpecificRevision($revision_number);
298  if ($existing_revision instanceof FileRevision) {
299  $info_resolver = new ClonedRevisionInfoResolver(
300  $resource->getMaxRevision(false) + 1,
301  $existing_revision
302  );
303 
304  $cloned_revision = $this->revision_repository->blankFromClone(
305  $info_resolver,
306  $resource,
307  $existing_revision
308  );
309 
310  $this->populateRevisionInfo($cloned_revision, $info_resolver);
311 
312  $resource->addRevision($cloned_revision);
313  $resource->setStorageID(
314  $resource->getStorageID() === '' ? $this->primary_storage_handler->getID() : $resource->getStorageID()
315  );
316  return $resource;
317  }
318  return $resource;
319  }
320 
322  StorableResource $resource,
323  Revision $new_revision,
324  InfoResolver $info_resolver
325  ): Revision {
326  $current_revision = $resource->getCurrentRevisionIncludingDraft();
327  $stream_replacement = new StreamReplacementRevision(
328  $resource->getIdentification(),
329  $this->extractStream($new_revision)
330  );
331  $stream_replacement = $this->populateRevisionInfo($stream_replacement, $info_resolver);
332  $stream_replacement->setVersionNumber($current_revision->getVersionNumber());
333  $stream_replacement->setStatus(RevisionStatus::DRAFT);
334 
335  return $stream_replacement;
336  }
337 
341  public function has(ResourceIdentification $identification): bool
342  {
343  return $this->resource_repository->has($identification);
344  }
345 
350  public function store(StorableResource $resource): void
351  {
352  foreach ($resource->getAllRevisionsIncludingDraft() as $revision) {
353  $this->file_name_policy->check($revision->getInformation()->getSuffix());
354  }
355 
356  $r = $this->lock_handler->lockTables(
357  array_merge(
358  $this->resource_repository->getNamesForLocking(),
359  $this->revision_repository->getNamesForLocking(),
360  $this->information_repository->getNamesForLocking(),
361  $this->stakeholder_repository->getNamesForLocking()
362  ),
363  function () use ($resource): void {
364  $this->resource_repository->store($resource);
365 
366  foreach ($resource->getAllRevisionsIncludingDraft() as $revision) {
367  $this->storeRevision($revision, $resource);
368  }
369 
370  foreach ($resource->getStakeholders() as $stakeholder) {
371  $this->stakeholder_repository->register($resource->getIdentification(), $stakeholder);
372  }
373  }
374  );
375 
376  $r->runAndUnlock();
377  }
378 
382  public function clone(StorableResource $resource): StorableResource
383  {
384  $new_resource = $this->newBlank($resource->getType());
385  foreach ($resource->getStakeholders() as $stakeholder) {
386  $stakeholder = clone $stakeholder;
387  $new_resource->addStakeholder($stakeholder);
388  }
389 
390  foreach ($resource->getAllRevisionsIncludingDraft() as $existing_revision) {
391  if (!$existing_revision instanceof FileRevision) {
392  continue;
393  }
394  $info_resolver = new ClonedRevisionInfoResolver(
395  $existing_revision->getVersionNumber(),
396  $existing_revision
397  );
398 
399  $existing_revision = $this->stream_access->populateRevision($existing_revision);
400 
401  $cloned_revision = new FileStreamRevision(
402  $new_resource->getIdentification(),
403  $existing_revision->maybeStreamResolver()->getStream(),
404  true
405  );
406 
407  $this->populateRevisionInfo($cloned_revision, $info_resolver);
408  $cloned_revision->setVersionNumber($existing_revision->getVersionNumber());
409 
410  $new_resource->addRevision($cloned_revision);
411  }
412  $this->store($new_resource);
413  return $new_resource;
414  }
415 
420  public function storeRevision(Revision $revision, ?StorableResource $resource = null): void
421  {
422  $storage_handler = empty($revision->getStorageID())
423  ? $this->primary_storage_handler
424  : $this->storage_handler_factory->getHandlerForRevision($revision);
425 
426  if ($revision instanceof UploadedFileRevision) {
427  // check policies
428  $this->file_name_policy->check($revision->getInformation()->getSuffix());
429  $storage_handler->storeUpload($revision);
430  }
431  if ($revision instanceof FileStreamRevision) {
432  $storage_handler->storeStream($revision);
433  }
434  if ($revision instanceof CloneRevision) {
435  $storage_handler->cloneRevision($revision);
436  }
437  if ($revision instanceof StreamReplacementRevision) {
438  $storage_handler->streamReplacement($revision);
439  }
440  $this->revision_repository->store($revision);
441  $this->information_repository->store($revision->getInformation(), $revision);
442 
443  // we replace the revision with the populated one
444  if ($resource !== null) {
445  $replace_revision = new FileRevision($revision->getIdentification());
446  $replace_revision->setVersionNumber($revision->getVersionNumber());
447  $replace_revision->setOwnerId($revision->getOwnerId());
448  $replace_revision->setTitle($revision->getTitle());
449  $replace_revision->setStatus($revision->getStatus());
450  $replace_revision->setInformation($revision->getInformation());
451  $replace_revision->setStorageID($revision->getStorageID());
452 
453  $resource->replaceRevision($replace_revision);
454  }
455  }
456 
461  public function get(ResourceIdentification $identification): StorableResource
462  {
463  if (isset($this->resource_cache[$identification->serialize()])) {
464  return $this->resource_cache[$identification->serialize()];
465  }
466  $resource = $this->resource_repository->get($identification);
467 
468  if ($this->auto_migrate && $resource->getStorageID() !== $this->primary_storage_handler->getID()) {
469  global $DIC;
471  $migrator = $DIC[\InitResourceStorage::D_MIGRATOR];
472  $migrator->migrate($resource, $this->primary_storage_handler->getID());
473  $resource->setStorageID($this->primary_storage_handler->getID());
474  }
475 
476  $this->resource_cache[$identification->serialize()] = $this->populateNakedResourceWithRevisionsAndStakeholders(
477  $resource
478  );
479 
480  return $this->resource_cache[$identification->serialize()];
481  }
482 
483  public function publish(StorableResource $resource): bool
484  {
485  $revision = $resource->getCurrentRevisionIncludingDraft();
486  if ($revision->getStatus() === RevisionStatus::PUBLISHED) {
487  return false;
488  }
489  $revision->setStatus(RevisionStatus::PUBLISHED);
490  $this->store($resource);
491  return true;
492  }
493 
494  public function unpublish(StorableResource $resource): bool
495  {
496  $revision = $resource->getCurrentRevisionIncludingDraft();
497  if ($revision->getStatus() === RevisionStatus::DRAFT) {
498  return false;
499  }
500  $revision->setStatus(RevisionStatus::DRAFT);
501  $this->store($resource);
502  return true;
503  }
504 
505  public function extractStream(Revision $revision): FileStream
506  {
507  switch (true) {
508  case $revision instanceof FileStreamRevision:
509  return Streams::ofReattachableResource($revision->getStream()->detach());
510  case $revision instanceof UploadedFileRevision:
511  return Streams::ofReattachableResource(fopen($revision->getUpload()->getPath(), 'rb'));
512  case $revision instanceof CloneRevision:
513  return $revision->getRevisionToClone()->getStream();
514  case $revision instanceof FileRevision:
515  if ($revision->getStorageID() !== '') {
516  return $this->storage_handler_factory->getHandlerForRevision(
517  $revision
518  )->getStream($revision);
519  }
520 
521  return $this->storage_handler_factory->getHandlerForResource(
522  $this->get($revision->getIdentification())
523  )->getStream($revision);
524  default:
525  throw new \LogicException('This revision type is not supported');
526  }
527  }
528 
534  public function remove(StorableResource $resource, ResourceStakeholder $stakeholder = null): bool
535  {
536  $sucessful = true;
537  if ($stakeholder instanceof ResourceStakeholder) {
538  $this->stakeholder_repository->deregister($resource->getIdentification(), $stakeholder);
539  $sucessful = $stakeholder->resourceHasBeenDeleted($resource->getIdentification());
540  $resource->removeStakeholder($stakeholder);
541  if ($resource->getStakeholders() !== []) {
542  return $sucessful;
543  }
544  }
545  foreach ($resource->getStakeholders() as $s) {
546  $sucessful = $s->resourceHasBeenDeleted($resource->getIdentification()) && $sucessful;
547  }
548 
549  foreach ($resource->getAllRevisionsIncludingDraft() as $revision) {
550  $this->deleteRevision($resource, $revision);
551  }
552 
553  $this->storage_handler_factory->getHandlerForResource($resource)->deleteResource($resource);
554  $this->resource_repository->delete($resource);
555 
556  return $sucessful;
557  }
558 
559  public function removeRevision(StorableResource $resource, int $revision_number): void
560  {
561  $reveision_to_delete = $resource->getSpecificRevision($revision_number);
562  if ($reveision_to_delete !== null) {
563  $this->deleteRevision($resource, $reveision_to_delete);
564  }
565  $this->store($resource);
566  }
567 
568  // Container Actions
571  string $path_inside_container,
572  ): bool {
573  $revision = $container->getCurrentRevisionIncludingDraft();
574  $stream = $this->extractStream($revision);
575 
576  // create directory inside ZipArchive
577  try {
578  $zip = new \ZipArchive();
579  $zip->open($stream->getMetadata()['uri']);
580  $path_inside_container = $this->ensurePathInZIP($zip, $path_inside_container, false);
581  $zip->close();
582 
583  // cleanup revision and flavours
584  $this->storage_handler_factory->getHandlerForRevision($revision)->clearFlavours($revision);
585  $revision->getInformation()->setSize(filesize($stream->getMetadata()['uri']));
586  $this->storeRevision($revision);
587 
588  return true;
589  } catch (\Throwable $exception) {
590  return false;
591  }
592  }
593 
594  private function ensurePathInZIP(\ZipArchive $zip, string $path, bool $is_file): string
595  {
596  if ($path === '' || $path === '/') {
597  return $path;
598  }
599 
600  $filename = '';
601  if ($is_file) {
602  $filename = basename($path);
603  $path = dirname($path);
604  }
605 
606  // try to determine if a path inside the zip exists with or without a slash at the beginning
607  // determine root directory of the path using regex
608  $parts = explode('/', $path);
609  $root = array_shift($parts);
610  $root = $root === '' ? array_shift($parts) : $root;
611 
612  // check if the root directory exists without a slash at the beginning
613  if ($zip->locateName($root . '/') !== false) {
614  $root = $root;
615  } elseif ($zip->locateName('/' . $root . '/') !== false) {
616  // check if the root directory exists with a slash at the beginning
617  $root = '/' . $root;
618  } else {
619  // if the root directory does not exist, create it
620  $zip->addEmptyDir($root);
621  }
622 
623  $path_inside_container = $root;
624  foreach ($parts as $part) {
625  $path_inside_container .= '/' . $part;
626  if ($zip->locateName($path_inside_container . '/') === false) {
627  $zip->addEmptyDir($path_inside_container . '/');
628  }
629  }
630 
631  return rtrim($path_inside_container, '/') . '/' . $filename;
632  }
633 
634  public function removePathInsideContainer(
636  string $path_inside_container,
637  ): bool {
638  $revision = $container->getCurrentRevisionIncludingDraft();
639  $stream = $this->extractStream($revision);
640 
641  // create directory inside ZipArchive
642  try {
643  $zip = new \ZipArchive();
644  $zip->open($stream->getMetadata()['uri']);
645 
646  $return = $zip->deleteName($path_inside_container);
647  // remove all files inside the directory
648  for ($i = 0; $i < $zip->numFiles; $i++) {
649  $path = $zip->getNameIndex($i);
650  if ($path === false) {
651  continue;
652  }
653  if (strpos($path, $path_inside_container) === 0) {
654  $zip->deleteIndex($i);
655  }
656  }
657 
658  $zip->close();
659 
660  // cleanup revision and flavours
661  $this->storage_handler_factory->getHandlerForRevision($revision)->clearFlavours($revision);
662  $revision->getInformation()->setSize(filesize($stream->getMetadata()['uri']));
663  $this->storeRevision($revision);
664 
665  return $return;
666  } catch (\Throwable $exception) {
667  $this->storage_handler_factory->getHandlerForRevision($revision)->clearFlavours($revision);
668  return false;
669  }
670  }
671 
672  public function addUploadToContainer(
674  UploadResult $result,
675  string $parent_path_inside_container,
676  ): bool {
677  $revision = $container->getCurrentRevisionIncludingDraft();
678  $stream = $this->extractStream($revision);
679 
680  // create directory inside ZipArchive
681  try {
682  $zip = new \ZipArchive();
683  $zip->open($stream->getMetadata()['uri']);
684 
685  $parent_path_inside_container = $this->ensurePathInZIP($zip, $parent_path_inside_container, false);
686 
687  $path_inside_zip = rtrim($parent_path_inside_container, '/') . '/' . $result->getName();
688 
689  $return = $zip->addFile(
690  $result->getPath(),
691  $path_inside_zip
692  );
693  $zip->close();
694 
695  // cleanup revision and flavours
696  $this->storage_handler_factory->getHandlerForRevision($revision)->clearFlavours($revision);
697  $revision->getInformation()->setSize(filesize($stream->getMetadata()['uri']));
698  $this->storeRevision($revision);
699 
700  return $return;
701  } catch (\Throwable $exception) {
702  return false;
703  }
704 
705  return true;
706  }
707 
708  public function addStreamToContainer(
710  FileStream $stream,
711  string $path_inside_container,
712  ): bool {
713  $revision = $container->getCurrentRevisionIncludingDraft();
714  $revision_stream = $this->extractStream($revision);
715 
716  try {
717  $zip = new \ZipArchive();
718  $zip->open($revision_stream->getMetadata()['uri']);
719 
720  $path_inside_container = $this->ensurePathInZIP($zip, $path_inside_container, true);
721 
722  $return = $zip->addFromString(
723  $path_inside_container,
724  (string) $stream
725  );
726  $zip->close();
727 
728  // cleanup revision and flavours
729  $this->storage_handler_factory->getHandlerForRevision($revision)->clearFlavours($revision);
730  $revision->getInformation()->setSize(filesize($revision_stream->getMetadata()['uri']));
731  $this->storeRevision($revision);
732 
733  return $return;
734  } catch (\Throwable $exception) {
735  return false;
736  }
737 
738  return true;
739  }
740 
741  private function deleteRevision(StorableResource $resource, Revision $revision): void
742  {
743  try {
744  $this->storage_handler_factory->getHandlerForResource($resource)->deleteRevision($revision);
745  } catch (\Throwable $exception) {
746  }
747 
748  $this->information_repository->delete($revision->getInformation(), $revision);
749  $this->revision_repository->delete($revision);
750  $resource->removeRevision($revision);
751  }
752 
754  {
755  $revisions = $this->revision_repository->get($resource);
756  $resource->setRevisions($revisions);
757 
758  foreach ($revisions->getAll(true) as $i => $revision) {
759  $information = $this->information_repository->get($revision);
760  $revision->setInformation($information);
761  $revision->setStorageID($resource->getStorageID());
762  // $revisions->replaceSingleRevision($this->stream_access->populateRevision($revision)); // currently we do not need populating the stream every time, we will do that in consumers only
763  }
764 
765  foreach ($this->stakeholder_repository->getStakeholders($resource->getIdentification()) as $s) {
766  $resource->addStakeholder($s);
767  }
768 
769  return $resource;
770  }
771 
772  private function populateRevisionInfo(Revision $revision, InfoResolver $info_resolver): Revision
773  {
774  $info = $revision->getInformation();
775 
776  $info->setTitle($this->secure($info_resolver->getFileName()));
777  $info->setMimeType($info_resolver->getMimeType());
778  $info->setSuffix($this->secure($info_resolver->getSuffix()));
779  $info->setSize($info_resolver->getSize());
780  $info->setCreationDate($info_resolver->getCreationDate());
781 
782  $revision->setInformation($info);
783  $revision->setTitle($this->secure($info_resolver->getRevisionTitle()));
784  $revision->setOwnerId($info_resolver->getOwnerId());
785 
786  return $revision;
787  }
788 }
populateRevisionInfo(Revision $revision, InfoResolver $info_resolver)
removePathInsideContainer(StorableContainerResource $container, string $path_inside_container,)
newFromStream(FileStream $stream, InfoResolver $info_resolver, bool $keep_original=false, ResourceType $type=ResourceType::SINGLE_FILE)
removeRevision(StorableResource $resource, int $revision_number)
replaceWithUpload(StorableResource $resource, UploadResult $result, InfoResolver $info_resolver)
replaceWithStream(StorableResource $resource, FileStream $stream, InfoResolver $info_resolver, bool $keep_original=false,)
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
clone(StorableResource $resource)
Clone anexisting resource with all it&#39;s revisions, stakeholders and information
storeRevision(Revision $revision, ?StorableResource $resource=null)
Store one Revision
__construct(StorageHandlerFactory $storage_handler_factory, Repositories $repositories, LockHandler $lock_handler, StreamAccess $stream_access, FileNamePolicy $file_name_policy=null)
ResourceBuilder constructor.
buildDraftReplacementRevision(StorableResource $resource, Revision $new_revision, InfoResolver $info_resolver)
setRevisions(RevisionCollection $collection)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addUploadToContainer(StorableContainerResource $container, UploadResult $result, string $parent_path_inside_container,)
ILIAS ResourceStorage Revision Repository RevisionRepository $revision_repository
ILIAS ResourceStorage Resource Repository ResourceRepository $resource_repository
$path
Definition: ltiservices.php:30
$container
Definition: wac.php:13
setInformation(Information $information)
createDirectoryInsideContainer(StorableContainerResource $container, string $path_inside_container,)
deleteRevision(StorableResource $resource, Revision $revision)
populateNakedResourceWithRevisionsAndStakeholders(StorableResource $resource)
getMaxRevision(bool $including_drafts=false)
global $DIC
Definition: shib_login.php:25
static ofReattachableResource($resource)
Definition: Streams.php:74
$filename
Definition: buildRTE.php:78
store(StorableResource $resource)
after you have modified a resource, you can store it here
ensurePathInZIP(\ZipArchive $zip, string $path, bool $is_file)
ILIAS ResourceStorage Policy FileNamePolicy $file_name_policy
appendFromStream(StorableResource $resource, FileStream $stream, InfoResolver $info_resolver, RevisionStatus $status, bool $keep_original=false,)
has(ResourceIdentification $identification)
check if a resource exists
ILIAS ResourceStorage Information Repository InformationRepository $information_repository
newBlank(ResourceType $type=ResourceType::SINGLE_FILE)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS ResourceStorage StorageHandler StorageHandler $primary_storage_handler
appendFromRevision(StorableResource $resource, int $revision_number)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
append(StorableResource $resource, UploadResult $result, InfoResolver $info_resolver, RevisionStatus $status)
The base interface for all filesystem streams.
Definition: FileStream.php:31
addStreamToContainer(StorableContainerResource $container, FileStream $stream, string $path_inside_container,)
ILIAS ResourceStorage Stakeholder Repository StakeholderRepository $stakeholder_repository
$r