startTimer(); $container = $this->container; $output = $container['output']; if ($output instanceof ResponseInterface) { return $output; } /** @var PageInterface $page */ $page = $this->container['page']; // Use internal Grav output. $container->output = $output; ob_start(); $event = new Event(['page' => $page, 'output' => &$container->output]); $container->fireEvent('onOutputGenerated', $event); echo $container->output; $html = ob_get_clean(); // remove any output $container->output = ''; $event = new Event(['page' => $page, 'output' => $html]); $this->container->fireEvent('onOutputRendered', $event); $this->stopTimer(); return new Response($page->httpResponseCode(), $page->httpHeaders(), $html); } }