ResourceLocator/src/UniformResourceLocator.php
public function addPath($scheme, $prefix, $paths, $override = false, $force = false)
    {
        $list = [];
        foreach((array) $paths as $path) {
            if (\is_array($path)) {
                // Support stream lookup in ['theme', 'path/to'] format.
                if (\count($path) !== 2 || !\is_string($path[0]) || !\is_string($path[1])) {
                    throw new \BadMethodCallException('Invalid stream path given.');
                }
                $list[] = $path;
            } elseif (false !== strpos($path, '://')) {
                // Support stream lookup in 'theme://path/to' format.
                $stream = explode('://', $path, 2);
                $stream[1] = trim($stream[1], '/');

                $list[] = $stream;
            } else {
                // Normalize path.
                $path = rtrim(str_replace('\\', '/', $path), '/');
                if ($force || @file_exists("{$this->base}/{$path}") || @file_exists($path)) {
                    // Support for absolute and relative paths.
                    $list[] = $path;
                }
            }
        }

        if (isset($this->schemes[$scheme][$prefix])) {
            $paths = $this->schemes[$scheme][$prefix];
            if (!$override || $override == 1) {
                $list = $override ? array_merge($paths, $list) : array_merge($list, $paths);
            } else {
                $location = array_search($override, $paths, true) ?: \count($paths);
                array_splice($paths, $location, 0, $list);
                $list = $paths;
            }
        }

        $this->schemes[$scheme][$prefix] = $list;

        // Sort in reverse order to get longer prefixes to be matched first.
        krsort($this->schemes[$scheme]);

        $this->cache = [];
    }
public function addPath($scheme, $prefix, $paths, $override = false, $force = false)
    {
        $list = [];
        foreach((array) $paths as $path) {
            if (\is_array($path)) {
                // Support stream lookup in ['theme', 'path/to'] format.
                if (\count($path) !== 2 || !\is_string($path[0]) || !\is_string($path[1])) {
                    throw new \BadMethodCallException('Invalid stream path given.');
                }
                $list[] = $path;
            } elseif (false !== strpos($path, '://')) {
                // Support stream lookup in 'theme://path/to' format.
                $stream = explode('://', $path, 2);
                $stream[1] = trim($stream[1], '/');

                $list[] = $stream;
            } else {
                // Normalize path.
                $path = rtrim(str_replace('\\', '/', $path), '/');
                if ($force || @file_exists("{$this->base}/{$path}") || @file_exists($path)) {
                    // Support for absolute and relative paths.
                    $list[] = $path;
                }
            }
        }

        if (isset($this->schemes[$scheme][$prefix])) {
            $paths = $this->schemes[$scheme][$prefix];
            if (!$override || $override == 1) {
                $list = $override ? array_merge($paths, $list) : array_merge($list, $paths);
            } else {
                $location = array_search($override, $paths, true) ?: \count($paths);
                array_splice($paths, $location, 0, $list);
                $list = $paths;
            }
        }

        $this->schemes[$scheme][$prefix] = $list;

        // Sort in reverse order to get longer prefixes to be matched first.
        krsort($this->schemes[$scheme]);

        $this->cache = [];
    }
public function addPath ( $ scheme , $ prefix , $ paths , $ override = false , $ force = false ) { $ list = [ ] ; foreach ( ( array ) $ paths as $ path ) { if ( \ is_array ( $ path ) ) { // Support stream lookup in ['theme', 'path/to'] format. if ( \ count ( $ path ) !== 2 || ! \ is_string ( $ path [ 0 ] ) || ! \ is_string ( $ path [ 1 ] ) ) { throw new \ BadMethodCallException ( 'Invalid stream path given.' ) ; } $ list [ ] = $ path ; } elseif ( false !== strpos ( $ path , '://' ) ) { // Support stream lookup in 'theme://path/to' format. $ stream = explode ( '://' , $ path , 2 ) ; $ stream [ 1 ] = trim ( $ stream [ 1 ] , '/' ) ; $ list [ ] = $ stream ; } else { // Normalize path. $ path = rtrim ( str_replace ( '\\' , '/' , $ path ) , '/' ) ; if ( $ force || @ file_exists ( "{$this->base}/{$path}" ) || @ file_exists ( $ path ) ) { // Support for absolute and relative paths. $ list [ ] = $ path ; } } } if ( isset ( $ this -> schemes [ $ scheme ] [ $ prefix ] ) ) { $ paths = $ this -> schemes [ $ scheme ] [ $ prefix ] ; if ( ! $ override || $ override == 1 ) { $ list = $ override ? array_merge ( $ paths , $ list ) : array_merge ( $ list , $ paths ) ; } else { $ location = array_search ( $ override , $ paths , true ) ? : \ count ( $ paths ) ; array_splice ( $ paths , $ location , 0 , $ list ) ; $ list = $ paths ; } } $ this -> schemes [ $ scheme ] [ $ prefix ] = $ list ; // Sort in reverse order to get longer prefixes to be matched first. krsort ( $ this -> schemes [ $ scheme ] ) ; $ this -> cache = [ ] ; }
Add new paths to the scheme.

@param string $scheme
@param string $prefix
@param string|array $paths
@param bool|string  $override  True to add path as override, string
@param bool  $force     True to add paths even if them do not exist.
@throws \BadMethodCallException
Add new paths to the scheme .