Пример #1
0
 /**
  * XXX write, test, use, document ...
  */
 public function getCacheUrlFor($packages, $extension)
 {
     $cacheKey = '';
     foreach ($packages as $package) {
         $cacheKey .= $package->getCacheKey();
     }
     return $this->configuration->getOption(Dynamics_Configuration::RELATIVE_ROOT_URL) . $this->getUrlFor(md5($cacheKey), $extension);
 }
Пример #2
0
 /**
  * Wrapper for doFilter method that tries to hide problems if we're not
  * debugging the application.
  *
  * @param  string $code -- unfiltered code
  * @return string       -- filtered code
  */
 public function filter($code)
 {
     try {
         return $this->doFilter($code);
     } catch (Exception $e) {
         if ($this->configuration->isDebug()) {
             throw $e;
         } else {
             return $code;
         }
     }
 }
Пример #3
0
 public static function run($filenames, $paths = array())
 {
     $name = self::getName();
     // create objects
     $configuration = new Dynamics_Configuration(array(Dynamics_Configuration::GLOBAL_ASSET_PATHS => $paths));
     $configuration->loadFromFiles($filenames);
     $dynamics = new Dynamics($configuration);
     $controller = new Dynamics_Controller($configuration);
     // run it
     $result = $controller->run($name);
     // display
     header(sprintf('Content-type: %s', $controller->getContentType()));
     die($result);
 }
Пример #4
0
 /**
  * generateSupercache - creates supercache file for given packages
  */
 public function generateSupercache($url, $packages, $type)
 {
     if (!$this->configuration->isSupercacheEnabled()) {
         throw new BadMethodCallException('Supercache is disabled.');
     }
     if (!file_exists($filename = $this->configuration->getOption(Dynamics_Configuration::WEB_DIR) . $url)) {
         $src = '';
         foreach ($packages as $name => $package) {
             if ($renderedSrc = trim($this->getAsset($name, $package, $type))) {
                 $src .= '/* ' . $name . ' */ ' . $renderedSrc . "\n";
             }
         }
         if (strlen($src)) {
             file_put_contents($filename, $src);
             if (!file_exists($filename)) {
                 throw new Exception('Supercache could not be written: ' . $filename);
             }
         } else {
             return false;
         }
     }
     return true;
 }
Пример #5
0
 public function render()
 {
     $loader = $this->configuration->getLoaderService();
     $renderer = $this->configuration->getRendererService();
     return $renderer->render($loader->getPackages());
 }