Ejemplo n.º 1
0
 /**
  * getAsset - render assets of a given type for a package
  *
  * @param  string                              $name
  * @param  sfDynamicsAssetCollectionDefinition $package
  * @param  string                              $type
  * @return string
  */
 public function getAsset($name, Dynamics_Configuration_Definition_AssetCollection $package, $type)
 {
     $extension = Dynamics::getExtensionFromType($type);
     $getAssets = 'get' . ucfirst($type) . 's';
     if (count($assets = $package->{$getAssets}())) {
         $paths = $package->getPaths($this->configuration->getGlobalAssetPaths());
         if ($this->configuration->isCacheEnabled()) {
             $cache = $this->configuration->getCacheService();
             $cacheKey = $cache->generateKey($package, $type);
             if ($cache->has($cacheKey)) {
                 if ($this->configuration->isCacheUpToDateCheckEnabled()) {
                     if ($cache->isStillUpToDate($package, $type, $cacheKey)) {
                         $result = $cache->get($cacheKey);
                     }
                 } else {
                     $result = $cache->get($cacheKey);
                 }
             }
         }
         // still no result? let's build it!
         if (!isset($result)) {
             $result = $this->configuration->getConcatenatedAssetFilterChainFor($type)->filter($this->getConcatenatedAssets($package, $paths, $assets));
             if ($this->configuration->isCacheEnabled()) {
                 $cache->set($cacheKey, $result);
             }
         }
         return $result;
     } else {
         return '';
     }
 }