/**
  * 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, sfDynamicsAssetCollectionDefinition $package, $type)
 {
     $extension = sfDynamics::getExtensionFromType($type);
     $getAssets = 'get' . ucfirst($type) . 's';
     if (count($assets = $package->{$getAssets}())) {
         $paths = $package->getPaths('/' . $extension);
         if (sfDynamicsConfig::isCacheEnabled()) {
             $cacheKey = sfDynamicsCache::generateKey($package, $type);
             $cache = sfDynamics::getCache();
             if ($cache->has($cacheKey)) {
                 if (sfDynamicsConfig::isCacheUpToDateCheckEnabled()) {
                     foreach ($assets as $asset) {
                         // this is needed to know the actual file path on disk, and to know its mtime.
                         $asset->computePath($paths);
                     }
                     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->getConcatenatedAssets($package, $paths, $assets);
             $result = sfDynamicsConfig::getConcatenatedAssetFilterChainFor($type)->filter($result);
             if (sfDynamicsConfig::isCacheEnabled()) {
                 $cache->set($cacheKey, $result);
             }
         }
         return $result;
     } else {
         return '';
     }
 }
 /**
  * supercache_for - build supercache filename or given packagelist and extension
  *
  * @param  string $packages
  * @param  string $extension
  * @return string
  */
 public static function supercache_for($packages, $extension)
 {
     $cacheKey = '';
     foreach ($packages as $package) {
         $cacheKey .= $package->getCacheKey();
     }
     return sfDynamicsCache::getSuperCacheDir() . '/' . md5($cacheKey) . '.' . $extension;
 }
예제 #3
0
<?php

$this->dispatcher->connect('routing.load_configuration', array('sfDynamicsRouting', 'configure'));
$this->dispatcher->connect('task.cache.clear', array('sfDynamicsCache', 'clearSuperCache'));
if (!is_writeable(sfDynamicsCache::getSuperCacheDir(true))) {
    $_superCacheDir = sfDynamicsCache::getSuperCacheDir(true);
    if (false !== strpos($_superCacheDir, '..')) {
        throw new sfConfigurationException('sfDynamicsPlugin supercache directory does not exists, and contains «..» components. Please check your configuration, or that «' . $_superCacheDir . '» is writeable.');
    }
    if (!@mkdir($_superCacheDir, 0777, true)) {
        throw new Exception(sprintf('Could not create dir «%s», check the permissions', $_superCacheDir));
    }
    if (!@chmod($_superCacheDir, 0777)) {
        throw new Exception(sprintf('Could not change owner dir «%s», check the permissions', $_superCacheDir));
    }
}