Ejemplo n.º 1
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;
 }