ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ContainerURIConsumer.php
Go to the documentation of this file.
1 <?php
2 
20 
25 use ILIAS\Data\URI;
27 
32 {
33  use GetRevisionTrait;
34 
35  private Archives $archives;
36  protected ?int $revision_number = null;
37  private StorableResource $resource;
38 
42  public function __construct(
43  private SrcBuilder $src_builder,
44  StorableContainerResource $resource,
45  private StreamAccess $stream_access,
46  private string $start_file,
47  private float $valid_for_at_least_minutes = 60.0
48  ) {
49  global $DIC;
50  $this->resource = $resource;
51  $this->archives = $DIC->archives();
52  }
53 
54  public function getURI(): ?URI
55  {
56  $filename = basename($this->start_file);
57  if ($filename === '') {
58  $filename = null;
59  }
60 
61  $startfile = urlencode($this->start_file); // e.g. for files with " " (spaces)
62  $startfile = str_replace(urlencode("/"), "/", $startfile); // we must keep directory sepparators
63 
64  $uri_string = $this->src_builder->getRevisionURL(
65  $this->stream_access->populateRevision($this->getRevision()),
66  true,
67  $this->valid_for_at_least_minutes,
68  $filename
69  ) . StreamDelivery::SUBREQUEST_SEPARATOR . $startfile;
70 
71  try {
72  return new URI($uri_string);
73  } catch (\Throwable) {
74  return null;
75  }
76  }
77 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:25
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:34
$filename
Definition: buildRTE.php:78
__construct(private SrcBuilder $src_builder, StorableContainerResource $resource, private StreamAccess $stream_access, private string $start_file, private float $valid_for_at_least_minutes=60.0)
DownloadConsumer constructor.