src/Listener/InjectTemplateListener.php
protected function resolveTemplate($controller, $moduleNamespace)
    {
        $class = get_class($controller);

        $server  = $this->getServer();
        $request = $server->getRequest();
        $action  = $request->getAttribute('action', 'index');

        if (0 !== strpos($class, $moduleNamespace)) {
            throw new UnexpectedValueException(sprintf(
                'The View Model of Controller "%s" returned unexpected module '
                . 'namespace "%s". If you want to use this module namespace, '
                . 'you need manually set a template to View Model.',
                $class,
                $moduleNamespace
            ));
        }

        $subNamespace = substr($class, strlen($moduleNamespace) + 1);
        $subNamespace = str_replace('Controller', '', $subNamespace);
        $subNamespace = str_replace('\\\\', '\\', $subNamespace);

        $path     = str_replace('\\', '/', $subNamespace) . '/' . $action;
        $template = strtolower(
            preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $path)
        );

        return $template;
    }
protected function resolveTemplate($controller, $moduleNamespace)
    {
        $class = get_class($controller);

        $server  = $this->getServer();
        $request = $server->getRequest();
        $action  = $request->getAttribute('action', 'index');

        if (0 !== strpos($class, $moduleNamespace)) {
            throw new UnexpectedValueException(sprintf(
                'The View Model of Controller "%s" returned unexpected module '
                . 'namespace "%s". If you want to use this module namespace, '
                . 'you need manually set a template to View Model.',
                $class,
                $moduleNamespace
            ));
        }

        $subNamespace = substr($class, strlen($moduleNamespace) + 1);
        $subNamespace = str_replace('Controller', '', $subNamespace);
        $subNamespace = str_replace('\\\\', '\\', $subNamespace);

        $path     = str_replace('\\', '/', $subNamespace) . '/' . $action;
        $template = strtolower(
            preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $path)
        );

        return $template;
    }
protected function resolveTemplate ( $ controller , $ moduleNamespace ) { $ class = get_class ( $ controller ) ; $ server = $ this -> getServer ( ) ; $ request = $ server -> getRequest ( ) ; $ action = $ request -> getAttribute ( 'action' , 'index' ) ; if ( 0 !== strpos ( $ class , $ moduleNamespace ) ) { throw new UnexpectedValueException ( sprintf ( 'The View Model of Controller "%s" returned unexpected module ' . 'namespace "%s". If you want to use this module namespace, ' . 'you need manually set a template to View Model.' , $ class , $ moduleNamespace ) ) ; } $ subNamespace = substr ( $ class , strlen ( $ moduleNamespace ) + 1 ) ; $ subNamespace = str_replace ( 'Controller' , '' , $ subNamespace ) ; $ subNamespace = str_replace ( '\\\\' , '\\' , $ subNamespace ) ; $ path = str_replace ( '\\' , '/' , $ subNamespace ) . '/' . $ action ; $ template = strtolower ( preg_replace ( '/([a-zA-Z])(?=[A-Z])/' , '$1-' , $ path ) ) ; return $ template ; }
Resolves template for received controller.

@param object $controller      The controller
@param string $moduleNamespace The module namespace

@throws \UnexpectedValueException If the controller namespace does not
match with namespace of module

@return string The template name
Resolves template for received controller .