MiniAsset\AssetConfig::load PHP Method

load() public method

Load a config file into the current instance.
public load ( string $path, string $prefix = '' )
$path string The config file to load.
$prefix string The string to prefix all targets in $path with.
    public function load($path, $prefix = '')
    {
        $config = $this->readConfig($path);
        foreach ($config as $section => $values) {
            if (in_array($section, self::$_extensionTypes)) {
                // extension section, merge in the defaults.
                $defaults = $this->get($section);
                if ($defaults) {
                    $values = array_merge($defaults, $values);
                }
                $this->addExtension($section, $values);
            } elseif (strtolower($section) === self::GENERAL) {
                $this->set(self::GENERAL, $values);
            } elseif (strpos($section, self::FILTER_PREFIX) === 0) {
                // filter section.
                $name = str_replace(self::FILTER_PREFIX, '', $section);
                $this->filterConfig($name, $values);
            } else {
                $lastDot = strrpos($section, '.') + 1;
                $extension = substr($section, $lastDot);
                $key = $section;
                // must be a build target.
                $this->addTarget($prefix . $key, $values);
            }
        }
        $this->resolveExtends();
        return $this;
    }

Usage Example

 /**
  * Load a config file and its `.local` file if it exists.
  *
  * @param \MiniAsset\AssetConfig $config The config object to update.
  * @param string $path The config file to load.
  * @param string $prefix The prefix to use.
  * @return void
  */
 protected function _load($config, $path, $prefix = '')
 {
     if (file_exists($path)) {
         $config->load($path, $prefix);
     }
     $localConfig = preg_replace('/(.*)\\.ini$/', '$1.local.ini', $path);
     if (file_exists($localConfig)) {
         $config->load($localConfig, $prefix);
     }
 }
All Usage Examples Of MiniAsset\AssetConfig::load