public function findViewFile($view, $context = null)
    {
        if (strncmp($view, '@', 1) === 0) {
            // e.g. "@app/views/main"
            $file = \Reaction::$app->getAlias($view);
        } elseif (strncmp($view, '//', 2) === 0) {
            // e.g. "//layouts/main"
            $file = Reaction::$app->getViewPath() . DIRECTORY_SEPARATOR . ltrim($view, '/');
        } elseif ($context instanceof ViewContextInterface) {
            $view = ltrim($view, '/');
            $file = $context->getViewPath() . DIRECTORY_SEPARATOR . $view;
        } elseif (($currentViewFile = $this->getViewFile()) !== false) {
            $file = dirname($currentViewFile) . DIRECTORY_SEPARATOR . $view;
        } else {
            throw new InvalidCallException("Unable to resolve view file for view '$view': no active view context.");
        }

        $pathInfo = pathinfo($file, PATHINFO_EXTENSION);
        if ($pathInfo !== '' && !empty($pathInfo)) {
            return $file;
        }
        $path = $file . '.' . $this->defaultExtension;
        if ($this->defaultExtension !== 'php' && !is_file($path)) {
            $path = $file . '.php';
        }

        return $path;
    }
public function findViewFile($view, $context = null)
    {
        if (strncmp($view, '@', 1) === 0) {
            // e.g. "@app/views/main"
            $file = \Reaction::$app->getAlias($view);
        } elseif (strncmp($view, '//', 2) === 0) {
            // e.g. "//layouts/main"
            $file = Reaction::$app->getViewPath() . DIRECTORY_SEPARATOR . ltrim($view, '/');
        } elseif ($context instanceof ViewContextInterface) {
            $view = ltrim($view, '/');
            $file = $context->getViewPath() . DIRECTORY_SEPARATOR . $view;
        } elseif (($currentViewFile = $this->getViewFile()) !== false) {
            $file = dirname($currentViewFile) . DIRECTORY_SEPARATOR . $view;
        } else {
            throw new InvalidCallException("Unable to resolve view file for view '$view': no active view context.");
        }

        $pathInfo = pathinfo($file, PATHINFO_EXTENSION);
        if ($pathInfo !== '' && !empty($pathInfo)) {
            return $file;
        }
        $path = $file . '.' . $this->defaultExtension;
        if ($this->defaultExtension !== 'php' && !is_file($path)) {
            $path = $file . '.php';
        }

        return $path;
    }
public function findViewFile ( $ view , $ context = null ) { if ( strncmp ( $ view , '@' , 1 ) === 0 ) { // e.g. "@app/views/main" $ file = \ Reaction :: $ app -> getAlias ( $ view ) ; } elseif ( strncmp ( $ view , '//' , 2 ) === 0 ) { // e.g. "//layouts/main" $ file = Reaction :: $ app -> getViewPath ( ) . DIRECTORY_SEPARATOR . ltrim ( $ view , '/' ) ; } elseif ( $ context instanceof ViewContextInterface ) { $ view = ltrim ( $ view , '/' ) ; $ file = $ context -> getViewPath ( ) . DIRECTORY_SEPARATOR . $ view ; } elseif ( ( $ currentViewFile = $ this -> getViewFile ( ) ) !== false ) { $ file = dirname ( $ currentViewFile ) . DIRECTORY_SEPARATOR . $ view ; } else { throw new InvalidCallException ( "Unable to resolve view file for view '$view': no active view context." ) ; } $ pathInfo = pathinfo ( $ file , PATHINFO_EXTENSION ) ; if ( $ pathInfo !== '' && ! empty ( $ pathInfo ) ) { return $ file ; } $ path = $ file . '.' . $ this -> defaultExtension ; if ( $ this -> defaultExtension !== 'php' && ! is_file ( $ path ) ) { $ path = $ file . '.php' ; } return $ path ; }
Finds the view file based on the given view name.
@param string $view the view name or the [path alias](guide:concept-aliases) of the view file. Please refer to [[render()]]
on how to specify this parameter.
@param object $context the context to be assigned to the view and can later be accessed via [[context]]
in the view. If the context implements [[ViewContextInterface]], it may also be used to locate
the view file corresponding to a relative view name.
@return string the view file path. Note that the file may not exist.
@throws InvalidCallException if a relative view name is given while there is no active context to
determine the corresponding view file.
Finds the view file based on the given view name .