/**
  * Validating the autoload generator class to use
  *
  * @param string $generator_class
  * @return bool
  */
 public static function validateAutoloadGenerator($generator_class)
 {
     if (class_exists($generator_class)) {
         $parents = class_parents($generator_class);
         $autoload_abstract = Config::getInternal('assets-autoload-generator-abstract');
         return in_array($autoload_abstract, $parents);
     }
     return false;
 }
 /**
  * Automatic assets loading from an Assets package declare in a `composer.json`
  *
  * @return void
  * @throws \DomainException if the preset doesn't exist or doesn't implement required interface
  * @throws \LogicException if the statement doesn't exist
  */
 public function load()
 {
     if (!empty($this->_statements)) {
         return;
     }
     foreach ($this->data as $type => $item) {
         if (!is_array($item)) {
             $item = array($item);
         }
         $use_statements = Config::get('use-statements');
         $adapter_name = isset($use_statements[$type]) ? $use_statements[$type] : null;
         if (!empty($adapter_name)) {
             $cls_name = 'AssetsManager\\Package\\PresetAdapter\\' . $adapter_name;
             if (@class_exists($cls_name)) {
                 $interfaces = class_implements($cls_name);
                 $config_interface = Config::getInternal('assets-preset-adapter-interface');
                 if (in_array($config_interface, $interfaces)) {
                     if (!isset($this->_statements[$type])) {
                         $this->_statements[$type] = array();
                     }
                     foreach ($item as $item_ctt) {
                         if (!is_array($item_ctt)) {
                             $item_ctt = array($item_ctt);
                         }
                         $statement = new $cls_name($item_ctt, $this);
                         $statement->parse();
                         $this->_statements[$type][] = $statement;
                     }
                 } else {
                     throw new \DomainException(sprintf('Preset statement class "%s" must implement interface "%s"!', $cls_name, $config_interface));
                 }
             } else {
                 throw new \DomainException(sprintf('Preset statement class "%s" not found!', $cls_name));
             }
         } else {
             throw new \LogicException(sprintf('Unknown preset statement type "%s" in preset "%s"!', $type, $this->getName()));
         }
     }
 }
 /**
  * Build a new preset instance
  *
  * @param   string $preset_name
  * @return  \AssetsManager\Package\Preset
  * @throws  \DomainException if the preset class can't be found or doesn't implement required interface
  * @throws  \InvalidArgumentException if the preset can't be found
  */
 protected function _buildNewPreset($preset_name)
 {
     $preset = isset($this->presets_data[$preset_name]) ? $this->presets_data[$preset_name]['data'] : null;
     if (!empty($preset)) {
         $package = $this->getPackage($this->presets_data[$preset_name]['package']);
         $cls_name = Config::get('assets-preset-class');
         if (@class_exists($cls_name)) {
             $interfaces = class_implements($cls_name);
             $config_interface = Config::getInternal('assets-preset-interface');
             if (in_array($config_interface, $interfaces)) {
                 $preset_object = new $cls_name($preset_name, $preset, $package);
                 return $preset_object;
             } else {
                 throw new \DomainException(sprintf('Preset class "%s" must implement interface "%s"!', $cls_name, $config_interface));
             }
         } else {
             throw new \DomainException(sprintf('Preset class "%s" not found!', $cls_name));
         }
     } else {
         throw new \InvalidArgumentException(sprintf('Unknown preset "%s"!', $preset_name));
     }
     return null;
 }