‪TYPO3CMS  ‪main
SelfEmittableLazyOpenStream.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 namespace ‪TYPO3\CMS\Core\Http;
19 
20 use GuzzleHttp\Psr7\LazyOpenStream;
21 use GuzzleHttp\Psr7\StreamDecoratorTrait;
22 use Psr\Http\Message\StreamInterface;
23 
32 {
33  use StreamDecoratorTrait;
34 
35  protected readonly LazyOpenStream ‪$stream;
36 
40  public function ‪__construct(protected readonly string $filename)
41  {
42  $this->stream = new LazyOpenStream($filename, 'r');
43  }
44 
48  public function ‪emit()
49  {
50  readfile($this->filename);
51  }
52 
53  public function ‪isWritable(): bool
54  {
55  return false;
56  }
57 
61  public function ‪write(string $string): int
62  {
63  throw new \RuntimeException('Cannot write to a ' . self::class, 1538331833);
64  }
65 
69  protected function ‪createStream(): StreamInterface
70  {
71  return $this->stream->stream;
72  }
73 }
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\__construct
‪__construct(protected readonly string $filename)
Definition: SelfEmittableLazyOpenStream.php:40
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\isWritable
‪isWritable()
Definition: SelfEmittableLazyOpenStream.php:53
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\createStream
‪createStream()
Definition: SelfEmittableLazyOpenStream.php:69
‪TYPO3\CMS\Core\Http\SelfEmittableStreamInterface
Definition: SelfEmittableStreamInterface.php:28
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\emit
‪emit()
Definition: SelfEmittableLazyOpenStream.php:48
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\$stream
‪readonly LazyOpenStream $stream
Definition: SelfEmittableLazyOpenStream.php:35
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\write
‪write(string $string)
Definition: SelfEmittableLazyOpenStream.php:61
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream
Definition: SelfEmittableLazyOpenStream.php:32
‪TYPO3\CMS\Core\Http
Definition: AbstractApplication.php:18