protected function renderInLayout(RequestApplicationInterface $app, $viewName, $params = [], $asResponse = false)
    {
        $view = $app->view;
        if (isset($this->layout)) {
            $layoutFile = $view->findViewFile($this->layout, $this);
        } else {
            $layoutFile = $view->findViewFile($view->layout, $this);
        }
        $content = $this->renderInternal($app, $viewName, $params, false, false);
        $rendered = $this->renderFile($app, $layoutFile, ['content' => $content]);
        if (!$asResponse) {
            return $rendered;
        }
        $app->response->setBody($rendered);
        return $app->response;
    }