public function onKernelController(FilterControllerEvent $event)
    {
        $request = $event->getRequest();
        $template = $request->attributes->get('_template');

        if (!$template instanceof Template) {
            return;
        }

        $controller = $event->getController();
        if (!\is_array($controller) && method_exists($controller, '__invoke')) {
            $controller = [$controller, '__invoke'];
        }
        $template->setOwner($controller);

        // when no template has been given, try to resolve it based on the controller
        if (null === $template->getTemplate()) {
            $template->setTemplate($this->templateGuesser->guessTemplateName($controller, $request));
        }
    }