public function onView(GetResponseForControllerResultEvent $event): void
    {
        $view = $event->getControllerResult();
        if (!$view instanceof ViewInterface) {
            return;
        }

        $response = $view->getResponse();
        if (!$response instanceof Response) {
            return;
        }

        $renderedView = '';

        try {
            $renderedView = $this->viewRenderer->renderView($view);
        } catch (Throwable $t) {
            $this->errorHandler->handleError($t);
        }

        $response->setContent($renderedView);

        $event->setResponse($response);
    }