‪TYPO3CMS  ‪main
FalDumpFileContentsDecoratorStream.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\StreamDecoratorTrait;
21 use Psr\Http\Message\StreamInterface;
22 use TYPO3\CMS\Core\Resource\Driver\DriverInterface;
23 
33 {
34  use StreamDecoratorTrait;
35 
36  public function ‪__construct(
37  protected readonly string ‪$identifier,
38  protected readonly DriverInterface $driver,
39  protected readonly int $size
40  ) {}
41 
46  public function ‪emit()
47  {
48  $this->driver->dumpFileContents($this->identifier);
49  }
50 
55  protected function ‪createStream(): StreamInterface
56  {
57  $stream = new ‪Stream('php://temp', 'rw');
58  $stream->write($this->driver->getFileContents($this->identifier));
59  return $stream;
60  }
61 
62  public function ‪getSize(): int
63  {
64  return $this->size;
65  }
66 
67  public function ‪isWritable(): bool
68  {
69  return false;
70  }
71 
75  public function ‪write(string $string): int
76  {
77  throw new \RuntimeException('Cannot write to a ' . self::class, 1538331852);
78  }
79 }
‪TYPO3\CMS\Core\Http\FalDumpFileContentsDecoratorStream\createStream
‪createStream()
Definition: FalDumpFileContentsDecoratorStream.php:55
‪TYPO3\CMS\Core\Http\FalDumpFileContentsDecoratorStream\emit
‪emit()
Definition: FalDumpFileContentsDecoratorStream.php:46
‪TYPO3\CMS\Core\Http\FalDumpFileContentsDecoratorStream\__construct
‪__construct(protected readonly string $identifier, protected readonly DriverInterface $driver, protected readonly int $size)
Definition: FalDumpFileContentsDecoratorStream.php:36
‪TYPO3\CMS\Core\Http\Stream
Definition: Stream.php:31
‪TYPO3\CMS\Core\Http\FalDumpFileContentsDecoratorStream\isWritable
‪isWritable()
Definition: FalDumpFileContentsDecoratorStream.php:67
‪TYPO3\CMS\Core\Http\FalDumpFileContentsDecoratorStream\write
‪write(string $string)
Definition: FalDumpFileContentsDecoratorStream.php:75
‪TYPO3\CMS\Core\Http\SelfEmittableStreamInterface
Definition: SelfEmittableStreamInterface.php:28
‪TYPO3\CMS\Core\Http\FalDumpFileContentsDecoratorStream
Definition: FalDumpFileContentsDecoratorStream.php:33
‪TYPO3\CMS\Core\Http\FalDumpFileContentsDecoratorStream\getSize
‪getSize()
Definition: FalDumpFileContentsDecoratorStream.php:62
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37
‪TYPO3\CMS\Core\Http
Definition: AbstractApplication.php:18