ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
PHP.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
36 final class PHP implements ilFileDeliveryType
37 {
41  protected $file;
42  protected \ILIAS\HTTP\Services $httpService;
43 
44 
50  public function __construct(Services $httpState)
51  {
52  $this->httpService = $httpState;
53  }
54 
55 
59  public function doesFileExists(string $path_to_file): bool
60  {
61  return is_readable($path_to_file);
62  }
63 
64 
68  public function prepare(string $path_to_file, ?FileStream $possible_stream): bool
69  {
70  set_time_limit(0);
71  if ($possible_stream !== null) {
72  $this->file = $possible_stream->detach();
73  } else {
74  $this->file = fopen($path_to_file, 'rb');
75  }
76  return true;
77  }
78 
79 
83  public function deliver(string $path_to_file, bool $file_marked_to_delete): void
84  {
85  $this->httpService->sendResponse();
86  fpassthru($this->file);
87  // Fix for mantis 22594
88  fclose($this->file);
89  }
90 
91 
95  public function supportsInlineDelivery(): bool
96  {
97  return true;
98  }
99 
100 
104  public function supportsAttachmentDelivery(): bool
105  {
106  return true;
107  }
108 
109 
113  public function supportsStreaming(): bool
114  {
115  return false;
116  }
117 
118 
122  public function handleFileDeletion(string $path_to_file): bool
123  {
124  return unlink($path_to_file);
125  }
126 }
deliver(string $path_to_file, bool $file_marked_to_delete)
absolute path to fileThis is needed at this point for header-based delivery methodsvoid ...
Definition: PHP.php:83
prepare(string $path_to_file, ?FileStream $possible_stream)
Definition: PHP.php:68
__construct(Services $httpState)
PHP constructor.
Definition: PHP.php:50
handleFileDeletion(string $path_to_file)
bool
Definition: PHP.php:122
ILIAS HTTP Services $httpService
Definition: PHP.php:42
The base interface for all filesystem streams.
Definition: FileStream.php:31
doesFileExists(string $path_to_file)
Definition: PHP.php:59