Пример #1
0
 /**
  *  add an Asset to this instance
  *  
  *  @param  Assetable $asset  any object that implements Assetable
  */
 public function add(Assetable $asset)
 {
     $this->asset_list[$asset->getName()] = $asset;
 }
Пример #2
0
 /**
  *  wrap parent to allow grouping by extension (handy for {@link render()})
  *  
  *  normally, assets are sorted by [name] but this sorts the assets by [ext][name]
  *  so you can easily call something like $this->render('css') to render all the css
  *  Assets      
  *      
  *  @see  parent::add()
  */
 public function add(Assetable $asset)
 {
     $name = $asset->getName();
     $ext = $asset->getExtension();
     $cleared = true;
     if (!isset($this->asset_list[$ext])) {
         $this->asset_list[$ext] = array();
     }
     //if
     // make sure this asset has all its dependencies cleared before adding it to the list
     if ($dependencies = $asset->getDependencies()) {
         foreach ($dependencies as $dependency_name) {
             if (!isset($this->asset_list[$ext][$dependency_name])) {
                 if (!isset($this->asset_dependency_map[$dependency_name])) {
                     $this->asset_dependency_map[$dependency_name] = array();
                 }
                 //if
                 $this->asset_dependency_map[$dependency_name][$name] = $asset;
                 $cleared = false;
             }
             //if
         }
         //foreach
     }
     //if
     if ($cleared) {
         $this->asset_list[$ext][$name] = $asset;
         // add any dependencies that rely on this asset
         if (isset($this->asset_dependency_map[$name])) {
             $this->asset_list[$ext] = array_merge($this->asset_list[$ext], $this->asset_dependency_map[$name]);
             unset($this->asset_dependency_map[$name]);
         }
         //if
     }
     //if
 }