ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilSecureTokenSrcBuilder.php
Go to the documentation of this file.
1 <?php
18 declare(strict_types=1);
19 
28 
33 {
35 
36  public function __construct(
37  private Services $file_delivery,
38  ) {
39  $this->inline = new InlineSrcBuilder($file_delivery);
40  }
41 
42  public function getRevisionURL(
43  Revision $revision,
44  bool $signed = true,
45  float $valid_for_at_least_minutes = 60.0,
46  string $filename = null
47  ): string {
48  // get stream from revision
49  $stream = $revision->maybeStreamResolver()?->getStream();
50 
51  return (string) $this->file_delivery->buildTokenURL(
52  $stream,
53  $filename ?? $revision->getTitle(),
54  Disposition::INLINE,
55  $GLOBALS['ilUser']->getId() ?? 0,
56  (int) (ceil($valid_for_at_least_minutes / 60))
57  );
58  }
59 
60  public function getFlavourURLs(Flavour $flavour, bool $signed = true): \Generator
61  {
62  foreach ($flavour->getStreamResolvers() as $stream_resolver) {
63  $stream = $stream_resolver->getStream();
64  if ($stream_resolver->isInMemory() || $stream->getMetadata()['uri'] === 'php://memory') {
65  // must deliver as data uri
66  yield $this->inline->buildDataURLFromStream($stream);
67  } else {
68  yield (string) $this->file_delivery->buildTokenURL(
69  $stream,
70  '',
71  Disposition::INLINE,
72  $GLOBALS['ilUser']->getId() ?? 0,
73  1
74  );
75  }
76  }
77  }
78 
79 }
$GLOBALS["DIC"]
Definition: wac.php:30
$filename
Definition: buildRTE.php:78
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(private Services $file_delivery,)
$file_delivery
Definition: deliver.php:13
getFlavourURLs(Flavour $flavour, bool $signed=true)
getRevisionURL(Revision $revision, bool $signed=true, float $valid_for_at_least_minutes=60.0, string $filename=null)