ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\FileDelivery\Services Class Reference
+ Collaboration diagram for ILIAS\FileDelivery\Services:

Public Member Functions

 __construct (private StreamDelivery $delivery, private LegacyDelivery $legacy_delivery, private DataSigner $data_signer, private \ILIAS\HTTP\Services $http)
 
 delivery ()
 
 legacyDelivery ()
 
 buildTokenURL (FileStream $stream, string $filename, Disposition $disposition, int $user_id, int $valid_for_at_least_hours)
 

Data Fields

const DELIVERY_ENDPOINT = '/deliver.php/'
 

Protected Member Functions

 getBaseURI ()
 

Private Attributes

string $base_uri = null
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 33 of file Services.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\FileDelivery\Services::__construct ( private StreamDelivery  $delivery,
private LegacyDelivery  $legacy_delivery,
private DataSigner  $data_signer,
private \ILIAS\HTTP\Services  $http 
)

Definition at line 39 of file Services.php.

44 {
45 }

Member Function Documentation

◆ buildTokenURL()

ILIAS\FileDelivery\Services::buildTokenURL ( FileStream  $stream,
string  $filename,
Disposition  $disposition,
int  $user_id,
int  $valid_for_at_least_hours 
)

Definition at line 57 of file Services.php.

63 : URI {
64 // a new DateTimeImmutable which is set to the end of now + $valid_for_at_least_hours hours
65 $valid_for_at_least_hours++;
66 $until = new \DateTimeImmutable(
67 (new \DateTimeImmutable("now +$valid_for_at_least_hours hours"))->format('Y-m-d H:00')
68 );
69
70 $token = $this->data_signer->getSignedStreamToken(
71 $stream,
73 $disposition,
75 $until
76 );
77
78 // maybe add suffix
79 $suffix = '';
80 // try to determine suffix from filename
81 $pathinfo = pathinfo($filename);
82 if (isset($pathinfo['extension']) && $pathinfo['extension'] !== '') {
83 $suffix = '.' . $pathinfo['extension'];
84 }
85
86 return new URI(
87 $this->getBaseURI() . self::DELIVERY_ENDPOINT . $token . $suffix
88 );
89 }
$filename
Definition: buildRTE.php:78
$token
Definition: xapitoken.php:70

◆ delivery()

ILIAS\FileDelivery\Services::delivery ( )

Definition at line 47 of file Services.php.

48 {
49 return $this->delivery;
50 }

◆ getBaseURI()

ILIAS\FileDelivery\Services::getBaseURI ( )
protected

Definition at line 91 of file Services.php.

91 : string
92 {
93 return $this->base_uri ?? $this->base_uri = rtrim(
94 $this->http->request()->getUri()->getScheme()
95 . '://' . $this->http->request()->getUri()->getHost()
96 . ($this->http->request()->getUri()->getPort() ? ':' . $this->http->request()->getUri()->getPort() : '')
97 . dirname($this->http->request()->getUri()->getPath()),
98 "/"
99 );
100 }
static http()
Fetches the global http state from ILIAS.

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ legacyDelivery()

ILIAS\FileDelivery\Services::legacyDelivery ( )

Definition at line 52 of file Services.php.

53 {
54 return $this->legacy_delivery;
55 }

Field Documentation

◆ $base_uri

string ILIAS\FileDelivery\Services::$base_uri = null
private

Definition at line 37 of file Services.php.

◆ DELIVERY_ENDPOINT

const ILIAS\FileDelivery\Services::DELIVERY_ENDPOINT = '/deliver.php/'

Definition at line 35 of file Services.php.


The documentation for this class was generated from the following file: