forked from kitodo/kitodo-presentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStdOutStream.php
More file actions
53 lines (46 loc) · 1.16 KB
/
StdOutStream.php
File metadata and controls
53 lines (46 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
* This file is part of the Kitodo and TYPO3 projects.
*
* @license GNU General Public License version 3 or later.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
namespace Kitodo\Dlf\Common;
use GuzzleHttp\Psr7\StreamDecoratorTrait;
use Psr\Http\Message\StreamInterface;
use TYPO3\CMS\Core\Http\SelfEmittableStreamInterface;
/**
* Stream decorator to allow printing a stream to standard output in chunks.
*
* @package TYPO3
* @subpackage dlf
*
* @access public
*/
class StdOutStream implements StreamInterface, SelfEmittableStreamInterface
{
use StreamDecoratorTrait;
/**
* Constructor
*/
public function __construct(protected readonly StreamInterface $stream)
{
}
/**
* @access public
*
* @return void
*/
public function emit()
{
// Disable output buffering
ob_end_flush();
// Stream content in chunks of 8KB
while (!$this->stream->eof()) {
echo $this->stream->read(8 * 1024);
}
}
}