ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer Class Reference
+ Inheritance diagram for ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer:
+ Collaboration diagram for ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer:

Public Member Functions

 __construct (Services $http, StorableResource $resource, StreamAccess $stream_access, FileNamePolicy $file_name_policy)
 
 run ()
 This runs the actual DeliveryConsumer. More...
 
- Public Member Functions inherited from ILIAS\ResourceStorage\Consumer\BaseConsumer
 __construct (protected StorableResource $resource, protected StreamAccess $stream_access, protected FileNamePolicy $file_name_policy)
 DownloadConsumer constructor. More...
 
 run ()
 This runs the actual DeliveryConsumer. More...
 
 setRevisionNumber (int $revision_number)
 @inheritDoc More...
 
 overrideFileName (string $file_name)
 
 run ()
 This runs the actual DeliveryConsumer. More...
 
 setRevisionNumber (int $revision_number)
 
 overrideFileName (string $file_name)
 

Protected Member Functions

 getDisposition ()
 

Private Attributes

const NON_VALID_EXTENSION_MIME = MimeType::APPLICATION__OCTET_STREAM
 
Services $http
 
StreamDelivery $delivery
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\ResourceStorage\Consumer\BaseConsumer
int $revision_number = null
 
string $file_name = ''
 

Detailed Description

Definition at line 34 of file BaseHTTPResponseBasedConsumer.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer::__construct ( Services  $http,
StorableResource  $resource,
StreamAccess  $stream_access,
FileNamePolicy  $file_name_policy 
)

Definition at line 41 of file BaseHTTPResponseBasedConsumer.php.

46 {
47 global $DIC;
48 $this->delivery = $DIC->fileDelivery()->delivery();
49 parent::__construct($resource, $stream_access, $file_name_policy);
50 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDisposition()

ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer::getDisposition ( )
abstractprotected

◆ run()

ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer::run ( )

This runs the actual DeliveryConsumer.

E.g. a DownloadConsumer will pass the Stream of a Ressource to the HTTP-Service and download the file.

Reimplemented from ILIAS\ResourceStorage\Consumer\BaseConsumer.

Definition at line 54 of file BaseHTTPResponseBasedConsumer.php.

54 : void
55 {
56 $revision = $this->getRevision();
57 $filename_with_extension = $this->file_name ?? $revision->getInformation()->getTitle();
58 $extension = pathinfo($filename_with_extension, PATHINFO_EXTENSION);
59 $file_name_for_consumer = $this->file_name_policy->prepareFileNameForConsumer($filename_with_extension);
60
61 $mime_type = $this->file_name_policy->isValidExtension($extension)
62 ? $revision->getInformation()->getMimeType()
64
65 // Build Response
66 $revision = $this->stream_access->populateRevision($revision);
67
68 match ($this->getDisposition()) {
69 'attachment' => $this->delivery->attached(
70 $revision->maybeStreamResolver()?->getStream(),
71 $file_name_for_consumer,
72 $mime_type
73 ),
74 'inline' => $this->delivery->inline(
75 $revision->maybeStreamResolver()?->getStream(),
76 $file_name_for_consumer,
77 $mime_type
78 ),
79 default => throw new \InvalidArgumentException('Invalid disposition'),
80 };
81 }

References ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer\getDisposition(), and ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer\NON_VALID_EXTENSION_MIME.

+ Here is the call graph for this function:

Field Documentation

◆ $delivery

StreamDelivery ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer::$delivery
private

Definition at line 39 of file BaseHTTPResponseBasedConsumer.php.

◆ $http

Services ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer::$http
private

Definition at line 38 of file BaseHTTPResponseBasedConsumer.php.

◆ NON_VALID_EXTENSION_MIME

const ILIAS\ResourceStorage\Consumer\BaseHTTPResponseBasedConsumer::NON_VALID_EXTENSION_MIME = MimeType::APPLICATION__OCTET_STREAM
private

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