示例#1
0
 /**
  * {@inheritdoc}
  */
 public function write($path, $contents, array $config = array())
 {
     $path = Util::normalizePath($path);
     $this->assertAbsent($path);
     $config = $this->prepareConfig($config);
     return (bool) $this->adapter->write($path, $contents, $config);
 }
示例#2
0
 /**
  * Write a new file to the source and replica
  *
  * @param   string $path
  * @param   string $contents
  * @param   mixed  $config Config object or visibility setting
  *
  * @return  false|array  false on failure file meta data on success
  */
 public function write($path, $contents, $config = null)
 {
     if (!$this->source->write($path, $contents, $config)) {
         return false;
     }
     return $this->replica->write($path, $contents, $config);
 }
 public function it_should_ignore_failed_writes()
 {
     $path = 'path.txt';
     $contents = 'contents';
     $config = new Config();
     $this->adapter->write($path, $contents, $config)->willReturn(false);
     $this->write($path, $contents, $config)->shouldBe(false);
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 public function write($path, $contents, Config $config)
 {
     $result = $this->adapter->write($path, $contents, $config);
     if ($result !== false) {
         $this->cache->updateObject($path, $result + compact('path', 'contents'), true);
     }
     return $result;
 }
 /**
  * {@inheritDoc}
  */
 public function write($path, $contents, Config $config)
 {
     $success = $this->adapter->write($path, $contents, $config);
     if ($success) {
         $this->cache->delete($this->getCacheKey($path));
     }
     return $success;
 }
 /**
  * {@inheritDoc}
  */
 public function write($path, $contents, Config $config)
 {
     $this->guardInUploadPath($path);
     if ($this->adapter->write($path, $contents, $config)) {
         \Dbafs::addResource($path);
         return true;
     }
     return false;
 }
示例#7
0
 /**
  * {@inheritdoc}
  */
 public function update($path, $contents, Config $config)
 {
     if (!$this->source->update($path, $contents, $config)) {
         return false;
     }
     if ($this->replica->has($path)) {
         return $this->replica->update($path, $contents, $config);
     } else {
         return $this->replica->write($path, $contents, $config);
     }
 }
示例#8
0
 /**
  * {@inheritdoc}
  */
 public function save()
 {
     $contents = $this->getForStorage();
     if ($this->adapter->has($this->file)) {
         $this->adapter->update($this->file, $contents);
     } else {
         $this->adapter->write($this->file, $contents);
     }
 }
示例#9
0
 /**
  * {@inheritdoc}
  */
 public function write($path, $contents, array $config = [])
 {
     $path = Util::normalizePath($path);
     $this->assertAbsent($path);
     $config = $this->prepareConfig($config);
     if (!($object = $this->adapter->write($path, $contents, $config))) {
         return false;
     }
     $this->cache->updateObject($path, $object + compact('contents'), true);
     return true;
 }
示例#10
0
 /**
  * Write a file
  *
  * @param  string              $path     path to file
  * @param  string              $contents file contents
  * @param  mixed               $config
  * @throws FileExistsException
  * @return boolean             success boolean
  */
 public function write($path, $contents, $config = null)
 {
     $path = Util::normalizePath($path);
     $this->assertAbsent($path);
     $config = Util::ensureConfig($config);
     $config->setFallback($this->getConfig());
     if (!($object = $this->adapter->write($path, $contents, $config))) {
         return false;
     }
     $this->cache->updateObject($path, $object, true);
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function read($path)
 {
     $result = $this->mainAdapter->read($path);
     if (false !== $result) {
         return $result;
     }
     $result = $this->fallback->read($path);
     if (false !== $result && $this->forceCopyOnMain) {
         $this->mainAdapter->write($path, $result['contents'], new Config());
     }
     return $result;
 }
示例#12
0
 /**
  * {@inheritdoc}
  */
 public function put(string $path, $contents, array $config = []) : bool
 {
     $config['visibility'] = $this->parseVisibility($config['visibility'] ?? null) ?: [];
     $flyConfig = new FlyConfig($config);
     if (is_resource($contents)) {
         if ($this->has($path)) {
             return (bool) $this->driver->updateStream($path, $resource, $flyConfig);
         }
         return (bool) $this->driver->writeStream($path, $resource, $flyConfig);
     }
     if ($this->has($path)) {
         return (bool) $this->driver->update($path, $contents, $flyConfig);
     }
     return (bool) $this->driver->write($path, $contents, $flyConfig);
 }
示例#13
0
 /**
  * İstenilen bir yere yükleme yapar.
  *
  * @param string $yol
  * @return bool
  */
 public function yukle($yol)
 {
     // dosyaların yüklenmesi tamam mı?
     if (!$this->isYuklemeTamam()) {
         throw new \RuntimeException('Dosyaların yüklenmesi ile ilgili bir sorun var.');
     }
     // adaptör set edilmiş olmalı
     if (!$this->adapter instanceof AdapterInterface) {
         throw new \RuntimeException('Yükleme yapmak için adaptör tanımlanmamış.');
     }
     // dosyalar üzerinde dönelim
     foreach ($this->dosyaBilgileri as $dosyaBilgisi) {
         // dosyayı yükleyelim
         $this->adapter->write($yol, file_get_contents($dosyaBilgisi->getPathname()), new Config());
     }
     // başarılı bir dönüş yapalım
     return true;
 }
示例#14
0
 /**
  * {@inheritdoc}
  */
 public function write($path, $contents, Config $config)
 {
     return $this->adapter->write($this->getPath($path), $contents, $config);
 }
示例#15
0
 function it_writes_file(AdapterInterface $adapter, Config $config)
 {
     $adapter->write('filename', 'Hello.', $config)->willReturn(array());
     $this->write('filename', 'Hello.')->shouldReturn(array());
 }
示例#16
0
 /**
  * {@inheritdoc}
  */
 public function write($key, $content)
 {
     return $this->adapter->write($key, $content, $this->config);
 }