Move output handling into the render processor

This commit is contained in:
Matias Griese
2017-04-21 12:23:19 +03:00
parent aee07203a2
commit bc9dfe736d
2 changed files with 19 additions and 17 deletions

View File

@@ -116,9 +116,6 @@ class Grav extends Container
*/
public function process()
{
/** @var Debugger $debugger */
$debugger = $this['debugger'];
// process all processors (e.g. config, initialize, assets, ..., render)
foreach ($this->processors as $processor) {
$processor = $this[$processor];
@@ -127,20 +124,10 @@ class Grav extends Container
});
}
$output = $this->output;
// Support for custom output providers like Slim Framework.
if (!$output instanceof \Psr\Http\Message\ResponseInterface) {
// Set the header type
$this->header();
echo $output;
}
/** @var Debugger $debugger */
$debugger = $this['debugger'];
$debugger->render();
$this->fireEvent('onOutputRendered');
register_shutdown_function([$this, 'shutdown']);
}

View File

@@ -15,7 +15,22 @@ class RenderProcessor extends ProcessorBase implements ProcessorInterface
public function process()
{
$this->container->output = $this->container['output'];
$this->container->fireEvent('onOutputGenerated');
$container = $this->container;
$output = $container['output'];
if ($output instanceof \Psr\Http\Message\ResponseInterface) {
// Support for custom output providers like Slim Framework.
} else {
// Use internal Grav output.
$container->output = $output;
$container->fireEvent('onOutputGenerated');
// Set the header type
$container->header();
echo $output;
}
$container->fireEvent('onOutputRendered');
}
}