Exemplo n.º 1
0
 /**
  * Caches a file for the current unique URL using the data type as part of its id.
  *
  * @access private
  * @param string $etag The current etag, will be replaced if new etag is generated
  * @return App\File
  */
 private function cache(&$etag)
 {
     $cache_id = $this->generateCacheId();
     $data_hash = md5($this->view);
     if (self::etag($cache_id, $etag, TRUE) && $etag == $data_hash) {
         return NULL;
     }
     self::etag($cache_id, $etag = $data_hash);
     if (!$this->type) {
         $extension = pathinfo($this->url->getPath(), PATHINFO_EXTENSION);
         $temp_file = $cache_id . ($extension ? '.' . $extension : NULL);
         $temp_file = new App\File(self::$cacheDirectory . DS . $temp_file);
         $temp_file->write($this->view);
         $this->type = $temp_file->getMimeType();
         if (!$extension && $this->type == 'text/plain') {
             $this->type = self::$defaultType;
         }
         $cache_id = $this->generateCacheId();
         $cache_file = $temp_file->rename($cache_id, TRUE);
         self::etag($cache_id, $data_hash);
     } else {
         $cache_file = new App\File(self::$cacheDirectory . DS . $cache_id);
     }
     return $cache_file;
 }
Exemplo n.º 2
0
 /**
  *
  */
 private function write()
 {
     if (!$this->outputFile) {
         throw new Flourish\ProgrammerException('Could not write scaffolded code, not output file specified');
     }
     $file = new App\File($this->outputFile);
     $file->write($this->code);
 }