/**
  * Add an minified file
  *
  * @param string $file_path The new CSS path
  * @param string $media The media type for the CSS file (default is "screen")
  * @return self
  * @throws \InvalidArgumentException if the path doesn't exist
  */
 public function addMinified($file_path, $media = 'screen')
 {
     $_fp = $this->__template->findAsset($file_path);
     if ($_fp || \AssetsManager\Loader::isUrl($file_path)) {
         $this->registry->addEntry(array('file' => $_fp, 'media' => $media), 'css_minified_files');
     } else {
         throw new \InvalidArgumentException(sprintf('CSS minified file "%s" not found!', $file_path));
     }
     return $this;
 }
 /**
  * Parse and transform the preset statement to a ready-to-use information
  *
  * The statement string can be constructed as (without spaces):
  *
  *     position : info : src
  *
  * where `position` can be an integer or a string like `top` or `bottom`, `info` can be
  * a string like `pack` for packed javascript or `min` for already minified scripts and
  * `src` is the relative path of the file in the original package. Position is a [-1;100]
  * integer range where 100 is the top of the stack (first files to include).
  *
  * By default, position is 0 (the file is added to the stack), and the script is considered
  * not minified neither as packed.
  *
  * @return void
  * @throws \Exception if one of the statements is malformed
  */
 public function parse()
 {
     if (!empty($this->transformed_data)) {
         return;
     }
     $data = $this->data;
     if (count($data) === 1 && !isset($data['src']) && isset($data[0])) {
         $data = array('src' => $data[0]);
     }
     $data = array_merge(self::$defaults, $data);
     $src = $data['src'];
     if (!empty($src)) {
         if (substr_count($src, ':')) {
             unset($data['src']);
             $substrs = explode(':', $src);
             if (count($substrs) > 3) {
                 throw new \Exception(sprintf('Statement js of preset "%s" is malformed (%s)!', $this->preset->getName(), $src));
             }
             foreach ($substrs as $substr) {
                 switch ($substr) {
                     case 'min':
                         $data['minified'] = true;
                         $data['packed'] = false;
                         break;
                     case 'pack':
                         $data['minified'] = false;
                         $data['packed'] = true;
                         break;
                     case 'first':
                         $data['position'] = Preset::FILES_STACK_FIRST;
                         break;
                     case 'last':
                         $data['position'] = Preset::FILES_STACK_LAST;
                         break;
                     default:
                         if (is_numeric($substr)) {
                             if (!(-1 <= $substr && 100 >= $substr)) {
                                 throw new \Exception(sprintf('A position must be in range [-1;100] for js statement of preset "%s" (got %s)!', $this->preset->getName(), $substr));
                             }
                             $data['position'] = $substr;
                         } else {
                             if (empty($data['src'])) {
                                 $data['src'] = $substr;
                             } else {
                                 throw new \Exception(sprintf('Misunderstood information "%s" for js statement of preset "%s"!', $substr, $this->preset->getName()));
                             }
                         }
                         break;
                 }
             }
         }
     } else {
         throw new \Exception(sprintf('No source file defined for statement js of preset "%s"!', $this->preset->getName()));
     }
     $this->transformed_data = $data;
     if (!\AssetsManager\Loader::isUrl($this->transformed_data['src'])) {
         $this->transformed_data['src'] = $this->preset->findInPackage($this->transformed_data['src']);
     }
 }
 /**
  * Find an asset file in the filesystem of a specific package
  *
  * @param string $filename The asset filename to find
  * @return string|null The web path of the asset if found, `null` otherwise
  */
 public function findInPackage($filename)
 {
     return AssetsLoader::findInPackage($filename, $this->getName());
 }
 /**
  * @return void
  * @throws \Exception caught calling required preset
  */
 public function parse()
 {
     if (!empty($this->dependencies)) {
         return;
     }
     $this->dependencies = array();
     $data = !is_array($this->data) ? array($this->data) : $this->data;
     foreach ($data as $preset_requires) {
         try {
             $preset = Loader::findPreset($preset_requires);
         } catch (\Exception $e) {
             throw new \Exception(sprintf('An error occurred trying to load a dependency for preset "%s" : "%s"', $this->preset->getName(), $e->getMessage()));
         }
         $this->dependencies[$preset_requires] = $preset;
     }
 }
 /**
  * Add a javascript file in javascript stack
  * 
  * @param string|array $file_path The new javascript path or an array like the `$_default_stack_entry`
  * @return self 
  * @throw Throws an InvalidArgumentException if the path doesn't exist
  */
 public function addIfExists($file_path)
 {
     $_fp = $this->__template->findAsset($file_path);
     if ($_fp || \AssetsManager\Loader::isUrl($file_path)) {
         return $this->add($file_path);
     }
     return $this;
 }