ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
Services.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\FileDelivery;
22 
27 use ILIAS\Data\URI;
28 
32 class Services
33 {
34  public const DELIVERY_ENDPOINT = '/src/FileDelivery/deliver.php/';
35 
36  public function __construct(
37  private \ILIAS\FileDelivery\Delivery\StreamDelivery $delivery,
38  private LegacyDelivery $legacy_delivery,
39  private DataSigner $data_signer
40  ) {
41  }
42 
43  public function delivery(): \ILIAS\FileDelivery\Delivery\StreamDelivery
44  {
45  return $this->delivery;
46  }
47 
48  public function legacyDelivery(): LegacyDelivery
49  {
50  return $this->legacy_delivery;
51  }
52 
53  public function buildTokenURL(
54  FileStream $stream,
55  string $filename,
56  Disposition $disposition,
57  int $user_id,
58  int $valid_for_at_least_hours
59  ): URI {
60  // a new DateTimeImmutable which is set to the end of now + $valid_for_at_least_hours hours
61  $valid_for_at_least_hours++;
62  $until = new \DateTimeImmutable(
63  (new \DateTimeImmutable("now +$valid_for_at_least_hours hours"))->format('Y-m-d H:00')
64  );
65 
66  $token = $this->data_signer->getSignedStreamToken(
67  $stream,
68  $filename,
69  $disposition,
70  $user_id,
71  $until
72  );
73  return new URI(
74  rtrim(ILIAS_HTTP_PATH, '/') . self::DELIVERY_ENDPOINT . $token
75  );
76  }
77 }
__construct(private \ILIAS\FileDelivery\Delivery\StreamDelivery $delivery, private LegacyDelivery $legacy_delivery, private DataSigner $data_signer)
Definition: Services.php:36
Class ChatMainBarProvider .
buildTokenURL(FileStream $stream, string $filename, Disposition $disposition, int $user_id, int $valid_for_at_least_hours)
Definition: Services.php:53
$token
Definition: xapitoken.php:70
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:18
$filename
Definition: buildRTE.php:78
Class Delivery.
Definition: Delivery.php:38
The base interface for all filesystem streams.
Definition: FileStream.php:31