Exemplo n.º 1
0
 /**
  * @param \Gaufrette\Filesystem $filesystem
  * @param \Gaufrette\Adapter $adapter
  */
 function it_should_not_set_metadata_by_default($filesystem, $adapter)
 {
     $metadata = array('id' => '123');
     $adapter->setMetadata('filename', $metadata)->shouldNotBeCalled();
     $filesystem->getAdapter()->willReturn($adapter);
     $this->setContent('some content', $metadata);
 }
Exemplo n.º 2
0
 protected function resolveFromGaufretteAdapter($id, GaufretteAdapter $adapter)
 {
     /** @todo Support other adapters */
     if ($adapter instanceof GaufretteAdapter\AwsS3) {
         $id = $adapter->getUrl($id);
     } else {
         throw new RuntimeException(sprintf('Gaufrette adapter of type "%s" is not supported', get_class($adapter)));
     }
     return $id;
 }
 /**
  * Write content to the primary adapter from the fallback
  */
 protected function writeContentToPrimary($key, $contents)
 {
     $this->primary->write($key, $contents);
     if ($this->primary instanceof Adapter\MetadataSupporter && $this->fallback instanceof Adapter\MetadataSupporter) {
         $this->primary->setMetadata($key, $this->fallback->getMetadata($key));
     }
 }
Exemplo n.º 4
0
 /**
  * Indicates whether the serialized cache file needs to be rebuild.
  *
  * @param string $cacheFile
  */
 public function needsRebuild($cacheFile)
 {
     $needsRebuild = true;
     if ($this->serializeCache->exists($cacheFile)) {
         try {
             $needsRebuild = time() - $this->ttl >= $this->serializeCache->mtime($cacheFile);
         } catch (\RuntimeException $e) {
         }
     }
     return $needsRebuild;
 }
Exemplo n.º 5
0
 /**
  * @param $key
  * @param $data
  * @return mixed
  */
 public function write($key, $data)
 {
     return $this->gaufretteAdapter->write($key, $data);
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function isDirectory($key)
 {
     return $this->master->isDirectory($key);
 }
 /**
  * @param \Gaufrette\Adapter $adapter
  */
 function it_does_not_calculate_checksum_of_file_which_does_not_exist($adapter)
 {
     $adapter->exists('filename')->shouldBeCalled()->willReturn(false);
     $this->shouldThrow(new \Gaufrette\Exception\FileNotFound('filename'))->duringChecksum('filename');
 }
 /**
  * @param \Gaufrette\Adapter $adapter
  */
 function it_delegates_keys($adapter)
 {
     $adapter->keys()->willReturn(array('filename', 'filename2'));
     $this->keys()->shouldReturn(array('filename', 'filename2'));
 }
Exemplo n.º 9
0
 /**
  * @param \Gaufrette\Adapter $source
  */
 function it_should_get_keys_from_source($source)
 {
     $source->keys()->willReturn(array('filename2', 'filename1', 'filename'));
     $this->keys()->shouldReturn(array('filename', 'filename1', 'filename2'));
 }
Exemplo n.º 10
0
 /**
  * @inheritdoc
  */
 public function isAvailable($value)
 {
     return !$this->adapter->exists($value);
 }
Exemplo n.º 11
0
 /**
  * @param \Gaufrette\Adapter $adapter
  */
 function it_should_not_delegate_metadata_when_delegate_object_does_not_support_it($adapter)
 {
     $adapter->setMetadata('filename', array('some'))->shouldNotBeCalled();
     $adapter->getMetadata('filename')->shouldNotBeCalled();
     $this->setMetadata('filename', array('some'));
     $this->getMetadata('filename')->shouldReturn(array());
 }