Update OccOutput.php
This commit is contained in:
@@ -2,42 +2,56 @@
|
|||||||
|
|
||||||
namespace OCA\OCCWeb\Controller;
|
namespace OCA\OCCWeb\Controller;
|
||||||
|
|
||||||
|
|
||||||
use Symfony\Component\Console\Output\BufferedOutput;
|
use Symfony\Component\Console\Output\BufferedOutput;
|
||||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||||
use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
|
||||||
class OccOutput extends BufferedOutput implements ConsoleOutputInterface
|
class OccOutput extends BufferedOutput implements ConsoleOutputInterface
|
||||||
{
|
{
|
||||||
private $consoleSectionOutputs = [];
|
private $consoleSectionOutputs = [];
|
||||||
|
|
||||||
private $stream;
|
private $stream;
|
||||||
/**
|
|
||||||
* Gets the OutputInterface for errors.
|
|
||||||
*
|
|
||||||
* @return OutputInterface
|
|
||||||
*/
|
|
||||||
public function getErrorOutput(): OutputInterface
|
public function getErrorOutput(): OutputInterface
|
||||||
{
|
{
|
||||||
// TODO: Implement getErrorOutput() method.
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setErrorOutput(OutputInterface $error)
|
public function setErrorOutput(OutputInterface $error)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function section(): ConsoleSectionOutput
|
||||||
* Creates a new output section.
|
{
|
||||||
*/
|
|
||||||
public function section(): ConsoleSectionOutput {
|
|
||||||
if ($this->stream === null) {
|
if ($this->stream === null) {
|
||||||
$this->stream = fopen('php://temp','w');
|
$this->stream = fopen('php://temp', 'w+');
|
||||||
}
|
}
|
||||||
return new ConsoleSectionOutput($this->stream, $this->consoleSectionOutputs, $this->getVerbosity(), $this->isDecorated(), $this->getFormatter());
|
return new ConsoleSectionOutput(
|
||||||
|
$this->stream,
|
||||||
|
$this->consoleSectionOutputs,
|
||||||
|
$this->getVerbosity(),
|
||||||
|
$this->isDecorated(),
|
||||||
|
$this->getFormatter()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fetch()
|
||||||
|
{
|
||||||
|
// Получаем основной буфер
|
||||||
|
$content = parent::fetch();
|
||||||
|
|
||||||
|
// Если есть stream от секций, читаем его тоже
|
||||||
|
if ($this->stream !== null) {
|
||||||
|
rewind($this->stream);
|
||||||
|
$streamContent = stream_get_contents($this->stream);
|
||||||
|
if ($streamContent !== false) {
|
||||||
|
$content .= $streamContent;
|
||||||
|
}
|
||||||
|
// Очищаем stream для следующего вызова
|
||||||
|
ftruncate($this->stream, 0);
|
||||||
|
rewind($this->stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user