protected function _paths($plugin = null, $cached = true)
    {
        if ($cached === true) {
            if ($plugin === null && !empty($this->_paths)) {
                return $this->_paths;
            }
            if ($plugin !== null && isset($this->_pathsForPlugin[$plugin])) {
                return $this->_pathsForPlugin[$plugin];
            }
        }
        $templatePaths = App::path(static::NAME_TEMPLATE);
        $pluginPaths = $themePaths = [];
        if (!empty($plugin)) {
            for ($i = 0, $count = count($templatePaths); $i < $count; $i++) {
                $pluginPaths[] = $templatePaths[$i] . 'Plugin' . DIRECTORY_SEPARATOR . $plugin . DIRECTORY_SEPARATOR;
            }
            $pluginPaths = array_merge($pluginPaths, App::path(static::NAME_TEMPLATE, $plugin));
        }

        if (!empty($this->theme)) {
            $themePaths = App::path(static::NAME_TEMPLATE, Inflector::camelize($this->theme));

            if ($plugin) {
                for ($i = 0, $count = count($themePaths); $i < $count; $i++) {
                    array_unshift($themePaths, $themePaths[$i] . 'Plugin' . DIRECTORY_SEPARATOR . $plugin . DIRECTORY_SEPARATOR);
                }
            }
        }

        $paths = array_merge(
            $themePaths,
            $pluginPaths,
            $templatePaths,
            [dirname(__DIR__) . DIRECTORY_SEPARATOR . static::NAME_TEMPLATE . DIRECTORY_SEPARATOR]
        );

        if ($plugin !== null) {
            return $this->_pathsForPlugin[$plugin] = $paths;
        }

        return $this->_paths = $paths;
    }
protected function _paths($plugin = null, $cached = true)
    {
        if ($cached === true) {
            if ($plugin === null && !empty($this->_paths)) {
                return $this->_paths;
            }
            if ($plugin !== null && isset($this->_pathsForPlugin[$plugin])) {
                return $this->_pathsForPlugin[$plugin];
            }
        }
        $templatePaths = App::path(static::NAME_TEMPLATE);
        $pluginPaths = $themePaths = [];
        if (!empty($plugin)) {
            for ($i = 0, $count = count($templatePaths); $i < $count; $i++) {
                $pluginPaths[] = $templatePaths[$i] . 'Plugin' . DIRECTORY_SEPARATOR . $plugin . DIRECTORY_SEPARATOR;
            }
            $pluginPaths = array_merge($pluginPaths, App::path(static::NAME_TEMPLATE, $plugin));
        }

        if (!empty($this->theme)) {
            $themePaths = App::path(static::NAME_TEMPLATE, Inflector::camelize($this->theme));

            if ($plugin) {
                for ($i = 0, $count = count($themePaths); $i < $count; $i++) {
                    array_unshift($themePaths, $themePaths[$i] . 'Plugin' . DIRECTORY_SEPARATOR . $plugin . DIRECTORY_SEPARATOR);
                }
            }
        }

        $paths = array_merge(
            $themePaths,
            $pluginPaths,
            $templatePaths,
            [dirname(__DIR__) . DIRECTORY_SEPARATOR . static::NAME_TEMPLATE . DIRECTORY_SEPARATOR]
        );

        if ($plugin !== null) {
            return $this->_pathsForPlugin[$plugin] = $paths;
        }

        return $this->_paths = $paths;
    }
protected function _paths ( $ plugin = null , $ cached = true ) { if ( $ cached === true ) { if ( $ plugin === null && ! empty ( $ this -> _paths ) ) { return $ this -> _paths ; } if ( $ plugin !== null && isset ( $ this -> _pathsForPlugin [ $ plugin ] ) ) { return $ this -> _pathsForPlugin [ $ plugin ] ; } } $ templatePaths = App :: path ( static :: NAME_TEMPLATE ) ; $ pluginPaths = $ themePaths = [ ] ; if ( ! empty ( $ plugin ) ) { for ( $ i = 0 , $ count = count ( $ templatePaths ) ; $ i < $ count ; $ i ++ ) { $ pluginPaths [ ] = $ templatePaths [ $ i ] . 'Plugin' . DIRECTORY_SEPARATOR . $ plugin . DIRECTORY_SEPARATOR ; } $ pluginPaths = array_merge ( $ pluginPaths , App :: path ( static :: NAME_TEMPLATE , $ plugin ) ) ; } if ( ! empty ( $ this -> theme ) ) { $ themePaths = App :: path ( static :: NAME_TEMPLATE , Inflector :: camelize ( $ this -> theme ) ) ; if ( $ plugin ) { for ( $ i = 0 , $ count = count ( $ themePaths ) ; $ i < $ count ; $ i ++ ) { array_unshift ( $ themePaths , $ themePaths [ $ i ] . 'Plugin' . DIRECTORY_SEPARATOR . $ plugin . DIRECTORY_SEPARATOR ) ; } } } $ paths = array_merge ( $ themePaths , $ pluginPaths , $ templatePaths , [ dirname ( __DIR__ ) . DIRECTORY_SEPARATOR . static :: NAME_TEMPLATE . DIRECTORY_SEPARATOR ] ) ; if ( $ plugin !== null ) { return $ this -> _pathsForPlugin [ $ plugin ] = $ paths ; } return $ this -> _paths = $ paths ; }
Return all possible paths to find view files in order

@param string|null $plugin Optional plugin name to scan for view files.
@param bool $cached Set to false to force a refresh of view paths. Default true.
@return array paths
Return all possible paths to find view files in order