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

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

All the class properties except 'js' and 'css' are accepted here. Also, an extra option 'autoload' may be passed containing an array of assets and/or collections that will be automatically added on startup.
public config ( array $config ) : Manager
$config array Configurable options.
Результат Manager
    public function config(array $config)
    {
        // Set regex options
        foreach (array('asset_regex', 'css_regex', 'js_regex', 'no_minification_regex') as $option) {
            if (isset($config[$option]) and @preg_match($config[$option], null) !== false) {
                $this->{$option} = $config[$option];
            }
        }
        // Set common options
        foreach (array('public_dir', 'css_dir', 'js_dir', 'packages_dir', 'pipeline', 'pipeline_dir', 'pipeline_gzip') as $option) {
            if (isset($config[$option])) {
                $this->{$option} = $config[$option];
            }
        }
        // Set pipeline options
        foreach (array('fetch_command', 'notify_command', 'css_minifier', 'js_minifier') as $option) {
            if (isset($config[$option]) and $config[$option] instanceof Closure) {
                $this->{$option} = $config[$option];
            }
        }
        // Set collections
        if (isset($config['collections']) and is_array($config['collections'])) {
            $this->collections = $config['collections'];
        }
        // Autoload assets
        if (isset($config['autoload']) and is_array($config['autoload'])) {
            foreach ($config['autoload'] as $asset) {
                $this->add($asset);
            }
        }
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * Set up configuration options.
  *
  * All the class properties except 'js' and 'css' are accepted here.
  * Also, an extra option 'autoload' may be passed containing an array of
  * assets and/or collections that will be automatically added on startup.
  *
  * @param  array   $config Configurable options.
  * @return Manager
  */
 public function config(array $config)
 {
     if (isset($config['collections_dir'])) {
         $this->collections_dir = $config['collections_dir'];
     } else {
         return parent::config($config);
         // @codeCoverageIgnore
     }
 }