Esempio n. 1
0
 /**
  * Transforms the config data into a more structured form
  *
  * @param array $contents Contents to build a config object from.
  * @return AssetConfig
  */
 protected static function _parseConfig($config, $constants)
 {
     $AssetConfig = new AssetConfig(self::$_defaults, $constants);
     foreach ($config as $section => $values) {
         if (in_array($section, self::$_extensionTypes)) {
             // extension section, merge in the defaults.
             $defaults = $AssetConfig->get($section);
             if ($defaults) {
                 $values = array_merge($defaults, $values);
             }
             $AssetConfig->addExtension($section, $values);
         } elseif (strtolower($section) === self::GENERAL) {
             $AssetConfig->set(self::GENERAL, $values);
         } elseif (strpos($section, self::FILTER_PREFIX) === 0) {
             // filter section.
             $name = str_replace(self::FILTER_PREFIX, '', $section);
             $AssetConfig->filterConfig($name, $values);
         } else {
             $lastDot = strrpos($section, '.') + 1;
             $extension = substr($section, $lastDot);
             $key = $section;
             // Is there a prefix? Chop it off.
             if (strpos($section, $extension . '_') !== false) {
                 $key = substr($key, strlen($extension) + 1);
             }
             // must be a build target.
             $AssetConfig->addTarget($key, $values);
         }
     }
     if ($AssetConfig->general('cacheConfig')) {
         Cache::write(self::CACHE_ASSET_CONFIG_KEY, $AssetConfig, self::CACHE_CONFIG);
     }
     return $AssetConfig;
 }