ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
SrcConsumer.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
4 
7 
13 {
14  use GetRevisionTrait;
15 
23  private $resource;
27  protected $revision_number;
28 
35  {
36  $this->resource = $resource;
37  $this->storage_handler = $storage_handler;
38  }
39 
40  public function getSrc() : string
41  {
42  $revision = $this->getRevision();
43  try {
44  $stream = $this->storage_handler->getStream($revision);
45  } catch (\Throwable $t) {
46  return '';
47  }
48 
49  $base64 = base64_encode($stream->getContents());
50  $mime = $revision->getInformation()->getMimeType();
51 
52  return "data:{$mime};base64,{$base64}";
53  }
54 
59  {
60  $this->revision_number = $revision_number;
61  return $this;
62  }
63 
64 }
__construct(StorableResource $resource, StorageHandler $storage_handler)
DownloadConsumer constructor.
Definition: SrcConsumer.php:34