protected function getTemplate(Request $request, $controller)
    {
        if ($request->attributes->has('_template')) {
            return null;
        }

        $format    = $request->attributes->get('_format', 'html');
        $templates = [];

        if ($controllerInfo = $this->parseController($controller)) {
            $template = sprintf('%s/%s.%s.twig', $controllerInfo['name'], $controllerInfo['action'], $format);

            if ($this->templateExists($template)) {
                return $template;
            } else {
                $templates[] = $template;
            }
        }

        $route = $this->routes->get($request->attributes->get('_route'));

        if ($route && $route->hasContent()) {
            $template = sprintf('%s/%s.%s.twig', $route->getContent(), $route->isList() ? 'list' : 'show', $format);

            if ($this->templateExists($template)) {
                return $template;
            } else {
                $templates[] = $template;
            }
        }

        return array_pop($templates);
    }
protected function getTemplate(Request $request, $controller)
    {
        if ($request->attributes->has('_template')) {
            return null;
        }

        $format    = $request->attributes->get('_format', 'html');
        $templates = [];

        if ($controllerInfo = $this->parseController($controller)) {
            $template = sprintf('%s/%s.%s.twig', $controllerInfo['name'], $controllerInfo['action'], $format);

            if ($this->templateExists($template)) {
                return $template;
            } else {
                $templates[] = $template;
            }
        }

        $route = $this->routes->get($request->attributes->get('_route'));

        if ($route && $route->hasContent()) {
            $template = sprintf('%s/%s.%s.twig', $route->getContent(), $route->isList() ? 'list' : 'show', $format);

            if ($this->templateExists($template)) {
                return $template;
            } else {
                $templates[] = $template;
            }
        }

        return array_pop($templates);
    }
protected function getTemplate ( Request $ request , $ controller ) { if ( $ request -> attributes -> has ( '_template' ) ) { return null ; } $ format = $ request -> attributes -> get ( '_format' , 'html' ) ; $ templates = [ ] ; if ( $ controllerInfo = $ this -> parseController ( $ controller ) ) { $ template = sprintf ( '%s/%s.%s.twig' , $ controllerInfo [ 'name' ] , $ controllerInfo [ 'action' ] , $ format ) ; if ( $ this -> templateExists ( $ template ) ) { return $ template ; } else { $ templates [ ] = $ template ; } } $ route = $ this -> routes -> get ( $ request -> attributes -> get ( '_route' ) ) ; if ( $ route && $ route -> hasContent ( ) ) { $ template = sprintf ( '%s/%s.%s.twig' , $ route -> getContent ( ) , $ route -> isList ( ) ? 'list' : 'show' , $ format ) ; if ( $ this -> templateExists ( $ template ) ) { return $ template ; } else { $ templates [ ] = $ template ; } } return array_pop ( $ templates ) ; }
Get template from the given request and controller

@param Request $request
@param mixed $controller

@return string|null
Get template from the given request and controller