‪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  protected string ‪$filename;
35  protected LazyOpenStream ‪$stream;
36 
42  public function ‪__construct(‪$filename)
43  {
44  $this->stream = new LazyOpenStream(‪$filename, 'r');
45  $this->filename = ‪$filename;
46  }
47 
51  public function ‪emit()
52  {
53  readfile($this->filename, false);
54  }
55 
56  public function ‪isWritable(): bool
57  {
58  return false;
59  }
60 
65  public function ‪write($string)
66  {
67  throw new \RuntimeException('Cannot write to a ' . self::class, 1538331833);
68  }
69 
73  protected function ‪createStream(): StreamInterface
74  {
75  return $this->stream->stream;
76  }
77 }
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\write
‪write($string)
Definition: SelfEmittableLazyOpenStream.php:65
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\isWritable
‪isWritable()
Definition: SelfEmittableLazyOpenStream.php:56
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\createStream
‪createStream()
Definition: SelfEmittableLazyOpenStream.php:73
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\$filename
‪string $filename
Definition: SelfEmittableLazyOpenStream.php:34
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\$stream
‪LazyOpenStream $stream
Definition: SelfEmittableLazyOpenStream.php:35
‪TYPO3\CMS\Core\Http\SelfEmittableStreamInterface
Definition: SelfEmittableStreamInterface.php:28
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\emit
‪emit()
Definition: SelfEmittableLazyOpenStream.php:51
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream
Definition: SelfEmittableLazyOpenStream.php:32
‪TYPO3\CMS\Core\Http
Definition: AbstractApplication.php:18
‪TYPO3\CMS\Core\Http\SelfEmittableLazyOpenStream\__construct
‪__construct($filename)
Definition: SelfEmittableLazyOpenStream.php:42