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;
    }