ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilSecureTokenSrcBuilder.php
Go to the documentation of this file.
1 <?php
18 declare(strict_types=1);
25 
30 {
32 
33  public function __construct(
34  private Services $file_delivery,
35  ) {
36  $this->inline = new InlineSrcBuilder($file_delivery);
37  }
38 
39  public function getRevisionURL(
40  Revision $revision,
41  bool $signed = true,
42  float $valid_for_at_least_minutes = 60.0,
43  ?string $filename = null
44  ): string {
45  // get stream from revision
46  $stream = $revision->maybeStreamResolver()?->getStream();
47 
48  return (string) $this->file_delivery->buildTokenURL(
49  $stream,
50  $filename ?? $revision->getTitle(),
51  Disposition::INLINE,
52  $GLOBALS['ilUser']->getId() ?? 0,
53  (int) (ceil($valid_for_at_least_minutes / 60))
54  );
55  }
56 
57  public function getFlavourURLs(Flavour $flavour, bool $signed = true): \Generator
58  {
59  foreach ($flavour->getStreamResolvers() as $stream_resolver) {
60  $stream = $stream_resolver->getStream();
61  if ($stream_resolver->isInMemory() || $stream->getMetadata()['uri'] === 'php://memory') {
62  // must deliver as data uri
63  yield $this->inline->buildDataURLFromStream($stream);
64  } else {
65  yield (string) $this->file_delivery->buildTokenURL(
66  $stream,
67  '',
68  Disposition::INLINE,
69  $GLOBALS['ilUser']->getId() ?? 0,
70  1
71  );
72  }
73  }
74  }
75 
76 }
getRevisionURL(Revision $revision, bool $signed=true, float $valid_for_at_least_minutes=60.0, ?string $filename=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$GLOBALS["DIC"]
Definition: wac.php:53
$filename
Definition: buildRTE.php:78
__construct(private Services $file_delivery,)
$file_delivery
Definition: deliver.php:29
getFlavourURLs(Flavour $flavour, bool $signed=true)