twig = $twig; $this->debugBar = $debugBar; } protected function renderInlineCss(array $files) { $css = ''; foreach ($files as $file) { $css .= file_get_contents($file); } return ""; } protected function renderHtml(Request $request, Response $response, string $template, array $parameters = []): Response { // If the path ends in .json, return the parameters if ('.json' == substr($request->getUri()->getPath(), -5, 5)) { return $this->jsonResponse($parameters, $request, $response); } $renderStart = microtime(true); $this->debugBar['time']->startMeasure('render', 'Time for rendering'); $response = $this->twig->render( $response, $template, $parameters )->withHeader('Content-Type', 'text/html'); $this->logger->debug(sprintf( 'Took %sms to render %s', number_format((microtime(true) - $renderStart) * 1000, 2), $template )); $this->debugBar['time']->stopMeasure('render'); return $response; } protected function pageNotFound(): Response { $response = (parent::pageNotFound()); $response->withHeader('Content-Type', 'text/html'); $response->getBody() ->write($this->twig->fetch($this->pageNotFoundTemplate)); return $response; } }