ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\LegalDocuments\Consumer\BaseHTTPResponseBasedConsumer Class Reference
+ Inheritance diagram for ILIAS\LegalDocuments\Consumer\BaseHTTPResponseBasedConsumer:
+ Collaboration diagram for ILIAS\LegalDocuments\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\LegalDocuments\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)
 
 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\LegalDocuments\Consumer\BaseConsumer
int $revision_number = null
 
string $file_name = ''
 

Detailed Description

Definition at line 34 of file BaseHTTPResponseBasedConsumer.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 41 of file BaseHTTPResponseBasedConsumer.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\LegalDocuments\Consumer\BaseHTTPResponseBasedConsumer\getDisposition().

46  {
47  global $DIC;
48  $this->delivery = $DIC->fileDelivery()->delivery();
49  parent::__construct($resource, $stream_access, $file_name_policy);
50  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getDisposition()

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

◆ run()

ILIAS\LegalDocuments\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.

Implements ILIAS\LegalDocuments\Consumer\DeliveryConsumer.

Definition at line 54 of file BaseHTTPResponseBasedConsumer.php.

References ILIAS\LegalDocuments\Consumer\BaseHTTPResponseBasedConsumer\getDisposition().

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()
63  : self::NON_VALID_EXTENSION_MIME;
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  }
+ Here is the call graph for this function:

Field Documentation

◆ $delivery

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

Definition at line 39 of file BaseHTTPResponseBasedConsumer.php.

◆ $http

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

Definition at line 38 of file BaseHTTPResponseBasedConsumer.php.

◆ NON_VALID_EXTENSION_MIME

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

Definition at line 37 of file BaseHTTPResponseBasedConsumer.php.


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