From bc9dfe736dc1bd2383b8d7a347d23c18006de4e8 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 21 Apr 2017 12:23:19 +0300 Subject: [PATCH] Move output handling into the render processor --- system/src/Grav/Common/Grav.php | 17 ++--------------- .../Common/Processors/RenderProcessor.php | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index 227f9e225..c2ccbbcb9 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -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']); } diff --git a/system/src/Grav/Common/Processors/RenderProcessor.php b/system/src/Grav/Common/Processors/RenderProcessor.php index b0b99120a..548151fe5 100644 --- a/system/src/Grav/Common/Processors/RenderProcessor.php +++ b/system/src/Grav/Common/Processors/RenderProcessor.php @@ -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'); } }