ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PHP.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26
36final class PHP implements ilFileDeliveryType
37{
41 protected $file;
42
43
49 public function __construct(protected Services $httpService)
50 {
51 }
52
53
57 public function doesFileExists(string $path_to_file): bool
58 {
59 return is_readable($path_to_file);
60 }
61
62
66 public function prepare(string $path_to_file, ?FileStream $possible_stream): bool
67 {
68 set_time_limit(0);
69 $this->file = $possible_stream !== null ? $possible_stream->detach() : fopen($path_to_file, 'rb');
70 return true;
71 }
72
73
77 public function deliver(string $path_to_file, bool $file_marked_to_delete): void
78 {
79 $this->httpService->sendResponse();
80 fpassthru($this->file);
81 // Fix for mantis 22594
82 fclose($this->file);
83 }
84
85
89 public function supportsInlineDelivery(): bool
90 {
91 return true;
92 }
93
94
98 public function supportsAttachmentDelivery(): bool
99 {
100 return true;
101 }
102
103
107 public function supportsStreaming(): bool
108 {
109 return false;
110 }
111
112
116 public function handleFileDeletion(string $path_to_file): bool
117 {
118 return unlink($path_to_file);
119 }
120}
prepare(string $path_to_file, ?FileStream $possible_stream)
bool
Definition: PHP.php:66
doesFileExists(string $path_to_file)
@inheritDoc
Definition: PHP.php:57
handleFileDeletion(string $path_to_file)
bool
Definition: PHP.php:116
__construct(protected Services $httpService)
PHP constructor.
Definition: PHP.php:49
deliver(string $path_to_file, bool $file_marked_to_delete)
void
Definition: PHP.php:77
Class Services.
Definition: Services.php:38
The base interface for all filesystem streams.
Definition: FileStream.php:32