src/Templating/TemplateGuesser.php
public function guessTemplateNames($controller, Request $request)
    {
        if (is_object($controller) && method_exists($controller, '__invoke')) {
            $controller = [$controller, '__invoke'];
        } elseif (!is_array($controller)) {
            throw new \InvalidArgumentException(sprintf('First argument of %s must be an array callable or an object defining the magic method __invoke. "%s" given.', __METHOD__, gettype($controller)));
        }

        if (!is_string($controller[0])) {
            $controller[0] = class_exists('Doctrine\Common\Util\ClassUtils')
                ? ClassUtils::getClass($controller[0])
                : get_class($controller[0]);
        }

        $reflClass = new \ReflectionClass($controller[0]);
        $templates = [];

        do {
            $controller[0] = $reflClass->getName();

            if ($template = $this->guessTemplateName($controller, $request)) {
                $templates[] = $template;
            }

            $reflClass = $reflClass->getParentClass();
        } while ($reflClass);

        return $templates;
    }
public function guessTemplateNames($controller, Request $request)
    {
        if (is_object($controller) && method_exists($controller, '__invoke')) {
            $controller = [$controller, '__invoke'];
        } elseif (!is_array($controller)) {
            throw new \InvalidArgumentException(sprintf('First argument of %s must be an array callable or an object defining the magic method __invoke. "%s" given.', __METHOD__, gettype($controller)));
        }

        if (!is_string($controller[0])) {
            $controller[0] = class_exists('Doctrine\Common\Util\ClassUtils')
                ? ClassUtils::getClass($controller[0])
                : get_class($controller[0]);
        }

        $reflClass = new \ReflectionClass($controller[0]);
        $templates = [];

        do {
            $controller[0] = $reflClass->getName();

            if ($template = $this->guessTemplateName($controller, $request)) {
                $templates[] = $template;
            }

            $reflClass = $reflClass->getParentClass();
        } while ($reflClass);

        return $templates;
    }
public function guessTemplateNames ( $ controller , Request $ request ) { if ( is_object ( $ controller ) && method_exists ( $ controller , '__invoke' ) ) { $ controller = [ $ controller , '__invoke' ] ; } elseif ( ! is_array ( $ controller ) ) { throw new \ InvalidArgumentException ( sprintf ( 'First argument of %s must be an array callable or an object defining the magic method __invoke. "%s" given.' , __METHOD__ , gettype ( $ controller ) ) ) ; } if ( ! is_string ( $ controller [ 0 ] ) ) { $ controller [ 0 ] = class_exists ( 'Doctrine\Common\Util\ClassUtils' ) ? ClassUtils :: getClass ( $ controller [ 0 ] ) : get_class ( $ controller [ 0 ] ) ; } $ reflClass = new \ ReflectionClass ( $ controller [ 0 ] ) ; $ templates = [ ] ; do { $ controller [ 0 ] = $ reflClass -> getName ( ) ; if ( $ template = $ this -> guessTemplateName ( $ controller , $ request ) ) { $ templates [ ] = $ template ; } $ reflClass = $ reflClass -> getParentClass ( ) ; } while ( $ reflClass ) ; return $ templates ; }
Guess multiple possible template names based on the controller

@param callable $controller An array storing the controller object and action method
@param Request  $request    A Request instance
@param string   $engine

@return string[] Array of template references

@throws \InvalidArgumentException
Guess multiple possible template names based on the controller