ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
StreamAccess.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 
34 {
35  public const PHP_MEMORY = 'php://memory';
36  private StorageHandlerFactory $storage_handler_factory;
37 
38  public function __construct(
39  string $storage_base_path,
40  StorageHandlerFactory $storage_handler_factory
41  ) {
42  $this->storage_handler_factory = $storage_handler_factory;
43  }
44 
45  public function populateRevision(Revision $revision): Revision
46  {
47  try {
48  $stream = $this->storage_handler_factory->getHandlerForRevision($revision)->getStream($revision);
49 
50  return $revision->withStreamResolver(new StreamResolver($stream));
51  } catch (FileNotFoundException) {
52  throw new \RuntimeException(
53  "Revision {$revision->getVersionNumber()} for Resource `{$revision->getIdentification()->serialize()}` not found in storage."
54  );
55  }
56  }
57 
58  public function populateFlavour(
59  Flavour $flavour,
60  FileStream $file_stream,
61  int $index
62  ): Flavour {
63  return $flavour->withStreamResolver(
64  $index,
65  new StreamResolver($file_stream)
66  );
67  }
68 }
populateFlavour(Flavour $flavour, FileStream $file_stream, int $index)
__construct(string $storage_base_path, StorageHandlerFactory $storage_handler_factory)