src/Common/Service/View.php
protected function resolvePath($sView)
    {
        $sCacheKey = 'path:' . $sView;
        $sCached   = $this->getCache($sCacheKey);
        if ($sCached !== null) {
            return $sCached;
        }

        $sView         = preg_replace('/\.php$/', '', $sView) . '.php';
        $sResolvedPath = '';
        $oRouter       = Factory::service('Router');

        if (strpos($sView, '/') !== 0) {

            foreach ($this->aViewPaths as $sPath) {

                $aPath = explode('/', $sView);
                if (count($aPath) > 1) {
                    $sModule = array_shift($aPath);
                    $sFile   = implode('/', $aPath);
                } else {
                    $sModule = '';
                    $sFile   = $sView;
                }

                $aPathOptions = array_filter([
                    [$sPath, $sModule, 'views', $sFile],
                    $oRouter->current_module() ? [$sPath, $oRouter->current_module(), 'views', $sModule, $sFile] : null,
                    [$sPath, 'views', $sModule, $sFile],
                ]);

                foreach ($aPathOptions as &$aPathOption) {
                    array_walk($aPathOption, function (&$sSegment) {
                        $sSegment = rtrim($sSegment, '/');
                    });
                    $aPathOption = implode('/', $aPathOption);
                }

                foreach ($aPathOptions as $sCompiledPath) {
                    if (file_exists($sCompiledPath)) {
                        $sResolvedPath = $sCompiledPath;
                        break 2;
                    }
                }
            }
        } else {
            $sResolvedPath = file_exists($sView) ? $sView : false;
        }

        if (!$sResolvedPath) {
            throw new ViewNotFoundException('Could not resolve view "' . $sView . '"');
        } elseif (!fileExistsCS($sResolvedPath)) {
            throw new ViewNotFoundCaseException('Incorrect casing for view "' . $sView . '"');
        }

        $this->setCache($sCacheKey, $sResolvedPath);

        return $sResolvedPath;
    }
protected function resolvePath($sView)
    {
        $sCacheKey = 'path:' . $sView;
        $sCached   = $this->getCache($sCacheKey);
        if ($sCached !== null) {
            return $sCached;
        }

        $sView         = preg_replace('/\.php$/', '', $sView) . '.php';
        $sResolvedPath = '';
        $oRouter       = Factory::service('Router');

        if (strpos($sView, '/') !== 0) {

            foreach ($this->aViewPaths as $sPath) {

                $aPath = explode('/', $sView);
                if (count($aPath) > 1) {
                    $sModule = array_shift($aPath);
                    $sFile   = implode('/', $aPath);
                } else {
                    $sModule = '';
                    $sFile   = $sView;
                }

                $aPathOptions = array_filter([
                    [$sPath, $sModule, 'views', $sFile],
                    $oRouter->current_module() ? [$sPath, $oRouter->current_module(), 'views', $sModule, $sFile] : null,
                    [$sPath, 'views', $sModule, $sFile],
                ]);

                foreach ($aPathOptions as &$aPathOption) {
                    array_walk($aPathOption, function (&$sSegment) {
                        $sSegment = rtrim($sSegment, '/');
                    });
                    $aPathOption = implode('/', $aPathOption);
                }

                foreach ($aPathOptions as $sCompiledPath) {
                    if (file_exists($sCompiledPath)) {
                        $sResolvedPath = $sCompiledPath;
                        break 2;
                    }
                }
            }
        } else {
            $sResolvedPath = file_exists($sView) ? $sView : false;
        }

        if (!$sResolvedPath) {
            throw new ViewNotFoundException('Could not resolve view "' . $sView . '"');
        } elseif (!fileExistsCS($sResolvedPath)) {
            throw new ViewNotFoundCaseException('Incorrect casing for view "' . $sView . '"');
        }

        $this->setCache($sCacheKey, $sResolvedPath);

        return $sResolvedPath;
    }
protected function resolvePath ( $ sView ) { $ sCacheKey = 'path:' . $ sView ; $ sCached = $ this -> getCache ( $ sCacheKey ) ; if ( $ sCached !== null ) { return $ sCached ; } $ sView = preg_replace ( '/\.php$/' , '' , $ sView ) . '.php' ; $ sResolvedPath = '' ; $ oRouter = Factory :: service ( 'Router' ) ; if ( strpos ( $ sView , '/' ) !== 0 ) { foreach ( $ this -> aViewPaths as $ sPath ) { $ aPath = explode ( '/' , $ sView ) ; if ( count ( $ aPath ) > 1 ) { $ sModule = array_shift ( $ aPath ) ; $ sFile = implode ( '/' , $ aPath ) ; } else { $ sModule = '' ; $ sFile = $ sView ; } $ aPathOptions = array_filter ( [ [ $ sPath , $ sModule , 'views' , $ sFile ] , $ oRouter -> current_module ( ) ? [ $ sPath , $ oRouter -> current_module ( ) , 'views' , $ sModule , $ sFile ] : null , [ $ sPath , 'views' , $ sModule , $ sFile ] , ] ) ; foreach ( $ aPathOptions as & $ aPathOption ) { array_walk ( $ aPathOption , function ( & $ sSegment ) { $ sSegment = rtrim ( $ sSegment , '/' ) ; } ) ; $ aPathOption = implode ( '/' , $ aPathOption ) ; } foreach ( $ aPathOptions as $ sCompiledPath ) { if ( file_exists ( $ sCompiledPath ) ) { $ sResolvedPath = $ sCompiledPath ; break 2 ; } } } } else { $ sResolvedPath = file_exists ( $ sView ) ? $ sView : false ; } if ( ! $ sResolvedPath ) { throw new ViewNotFoundException ( 'Could not resolve view "' . $ sView . '"' ) ; } elseif ( ! fileExistsCS ( $ sResolvedPath ) ) { throw new ViewNotFoundCaseException ( 'Incorrect casing for view "' . $ sView . '"' ) ; } $ this -> setCache ( $ sCacheKey , $ sResolvedPath ) ; return $ sResolvedPath ; }
Attempts to resolve the view path

@param string $sView The view to resolve

@return bool|string
@throws ViewNotFoundException
@throws ViewNotFoundCaseException
Attempts to resolve the view path