Exemplo n.º 1
0
 /**
  * @param array $files
  * @param string $type
  * @return string
  */
 public function getCompiledFile(array $files, $type)
 {
     $includedFiles = $this->cache->load($files);
     if ($includedFiles) {
         $modified = $this->getLastModification($includedFiles);
         $cacheKey = $this->getCacheKey($files);
         $cacheFile = $this->public->load($cacheKey, $modified, $type);
         if ($cacheFile) {
             return $this->public->getUrl() . '/' . pathinfo($cacheFile, PATHINFO_BASENAME) . '?' . $modified;
         }
     }
     $output = '';
     $includedFiles = array();
     $filters =& $this->{$type . 'Filters'};
     foreach ($files as $file) {
         $file = $this->resourcesDirectory . '/' . $file;
         if (!is_readable($file)) {
             throw new FileNotFoundException("File '{$file}' not found.");
         }
         $input = file_get_contents($file);
         $extension = pathinfo($file, PATHINFO_EXTENSION);
         if (isset($filters[$extension])) {
             if (!is_array($filters[$extension])) {
                 $filters[$extension] = (array) $filters[$extension];
             }
             foreach ($filters[$extension] as &$filter) {
                 if (is_string($filter)) {
                     $filter = $this->container->getService($filter);
                 }
                 $input = $filter($input, $file);
                 $includedFiles = array_merge($includedFiles, $filter->getIncludedFiles());
             }
         } elseif ($extension == 'css' || $extension == 'js') {
             $includedFiles[] = $file;
         } else {
             throw new InvalidStateException("Unknown extension '{$extension}'.");
         }
         $output .= $input;
     }
     $cacheKey = $this->getCacheKey($files);
     $this->cache->save($files, $includedFiles, array(\Nette\Caching\Cache::EXPIRE => '+ 1 month'));
     $cacheFile = $this->public->save($cacheKey, $output, $type);
     return $this->public->getUrl() . '/' . pathinfo($cacheFile, PATHINFO_BASENAME) . '?' . $this->getLastModification($includedFiles);
 }
 public function __construct($schemaXpath)
 {
     $uri = $schemaXpath->document->documentURI;
     if ($uri) {
         $key = sprintf('XmlDefaults(%s)', $uri);
         $this->defaults = PublicCache::cacheNamed($key, array('XmlDefaults', 'parseDefaults'), array($schemaXpath));
     } else {
         $this->defaults = self::parseDefaults($schemaXpath);
     }
 }
Exemplo n.º 3
0
 /**
  * Returns the matching PhpName.
  * Don't use this method directly.
  * Use the getRelatedMethodName() instead.
  *
  * @deprecated
  */
 public static function getPhpName($dbName, $tableName)
 {
     return PublicCache::cache(array('afMetaDb', '_getPhpName'), array($dbName, $tableName));
 }