Stolz\Assets\Manager::addDir PHP Метод

addDir() публичный Метод

Add all assets matching $pattern within $directory.
public addDir ( string $directory, string $pattern = null ) : Manager
$directory string Relative to $this->public_dir
$pattern string (regex)
Результат Manager
    public function addDir($directory, $pattern = null)
    {
        // Make sure directory exists
        $absolute_path = realpath($this->public_dir . DIRECTORY_SEPARATOR . $directory);
        if ($absolute_path === false) {
            return $this;
        }
        // By default match all assets
        if (is_null($pattern)) {
            $pattern = $this->asset_regex;
        }
        // Get assets files
        $files = $this->rglob($absolute_path, $pattern, $this->public_dir);
        // No luck? Nothing to do
        if (!$files) {
            return $this;
        }
        // Avoid polling if the pattern is our old friend JavaScript
        if ($pattern === $this->js_regex) {
            $this->js = array_unique(array_merge($this->js, $files));
        } elseif ($pattern === $this->css_regex) {
            $this->css = array_unique(array_merge($this->css, $files));
        } else {
            foreach ($files as $asset) {
                if (preg_match($this->js_regex, $asset)) {
                    $this->js[] = $asset;
                } elseif (preg_match($this->css_regex, $asset)) {
                    $this->css[] = $asset;
                }
            }
            $this->js = array_unique($this->js);
            $this->css = array_unique($this->css);
        }
        return $this;
    }