public function createView(string $class, string $method): View
    {
        if (false === method_exists($class, $method)) {
            throw new Exception('Could not create view');
        }

        $reflection = $this->container->getFactory($class)->getReflection();

        if (null === ($view = $reflection->getAnnotation('view', $method, null))) {
            throw new Exception('No view defined for ' . $class . '::' . $method);
        }

        if (class_exists($view)) {
            return new View($view);
        }

        $directory = realpath(dirname($reflection->getFileName()) . '/../' . self::DEFAULT_VIEW_PATH);
        $directory = $reflection->getAnnotation('viewPath', $method, $directory);

        $template = str_replace('/', DIRECTORY_SEPARATOR, $directory . '/' . $view);

        return $this->createViewFromTemplate($template);
    }
public function createView(string $class, string $method): View
    {
        if (false === method_exists($class, $method)) {
            throw new Exception('Could not create view');
        }

        $reflection = $this->container->getFactory($class)->getReflection();

        if (null === ($view = $reflection->getAnnotation('view', $method, null))) {
            throw new Exception('No view defined for ' . $class . '::' . $method);
        }

        if (class_exists($view)) {
            return new View($view);
        }

        $directory = realpath(dirname($reflection->getFileName()) . '/../' . self::DEFAULT_VIEW_PATH);
        $directory = $reflection->getAnnotation('viewPath', $method, $directory);

        $template = str_replace('/', DIRECTORY_SEPARATOR, $directory . '/' . $view);

        return $this->createViewFromTemplate($template);
    }
public function createView ( string $ class , string $ method ) : View { if ( false === method_exists ( $ class , $ method ) ) { throw new Exception ( 'Could not create view' ) ; } $ reflection = $ this -> container -> getFactory ( $ class ) -> getReflection ( ) ; if ( null === ( $ view = $ reflection -> getAnnotation ( 'view' , $ method , null ) ) ) { throw new Exception ( 'No view defined for ' . $ class . '::' . $ method ) ; } if ( class_exists ( $ view ) ) { return new View ( $ view ) ; } $ directory = realpath ( dirname ( $ reflection -> getFileName ( ) ) . '/../' . self :: DEFAULT_VIEW_PATH ) ; $ directory = $ reflection -> getAnnotation ( 'viewPath' , $ method , $ directory ) ; $ template = str_replace ( '/' , DIRECTORY_SEPARATOR , $ directory . '/' . $ view ) ; return $ this -> createViewFromTemplate ( $ template ) ; }
Initialize template or view from controller annotations

@param string $class controller class
@param string $method action method
@throws \ReflectionException
@throws \Janeiro\Di\Exception
@throws \Janeiro\Di\NotFoundException
@throws \Janeiro\Mvc\Exception
@return \Janeiro\Mvc\View
Initialize template or view from controller annotations