Ejemplo n.º 1
0
 /**
  * Handle the command.
  *
  * @param Filesystem $files
  */
 public function handle(Filesystem $files)
 {
     $entry = $this->fieldType->getEntry();
     $path = $this->fieldType->getStoragePath();
     if ($path && !is_dir(dirname($path))) {
         $files->makeDirectory(dirname($path), 0777, true, true);
     }
     if ($path) {
         $files->put($path, array_get($entry->getAttributes(), $this->fieldType->getField()));
     }
 }
Ejemplo n.º 2
0
 /**
  * Handle the command.
  *
  * @param  EntryRepositoryInterface $repository
  * @param Repository                $config
  * @return string
  */
 public function handle(EntryRepositoryInterface $repository, Repository $config)
 {
     $path = $this->fieldType->getStoragePath();
     $entry = $this->fieldType->getEntry();
     if (!file_exists($this->fieldType->getStoragePath())) {
         $this->dispatch(new PutFile($this->fieldType));
     }
     $content = $this->dispatch(new GetFile($this->fieldType));
     /**
      * If content is the same then
      * use the content - doesn't matter.
      */
     if (md5($content) == md5(array_get($entry->getAttributes(), $this->fieldType->getField()))) {
         return $content;
     }
     /**
      * If the file is newer and we're debugging
      * then update with the file's content.
      */
     if (filemtime($path) > $entry->lastModified()->timestamp && $config->get('app.debug')) {
         $repository->save($entry->setRawAttribute($this->fieldType->getField(), $content));
     }
     /**
      * If the file is newer and we're NOT debugging
      * then update with the file with the database.
      */
     if (filemtime($path) > $entry->lastModified()->timestamp && !$config->get('app.debug')) {
         $this->dispatch(new PutFile($this->fieldType));
         $content = array_get($entry->getAttributes(), $this->fieldType->getField());
     }
     /**
      * If the database is newer then update the file
      * since that is what we use anyways.
      */
     if (filemtime($path) < $entry->lastModified()->timestamp) {
         $this->dispatch(new PutFile($this->fieldType));
         $content = array_get($entry->getAttributes(), $this->fieldType->getField());
     }
     $this->dispatch(new ClearCache());
     return $content;
 }
Ejemplo n.º 3
0
 /**
  * Handle the command.
  *
  * @param EntryRepositoryInterface $repository
  * @return string
  */
 public function handle(EntryRepositoryInterface $repository)
 {
     $path = $this->fieldType->getStoragePath();
     $entry = $this->fieldType->getEntry();
     if (!file_exists($this->fieldType->getStoragePath())) {
         $this->dispatch(new PutFile($this->fieldType));
     }
     $content = $this->dispatch(new GetFile($this->fieldType));
     if (md5($content) == md5(array_get($entry->getAttributes(), $this->fieldType->getField()))) {
         return $content;
     }
     if (filemtime($path) > $entry->lastModified()->timestamp) {
         $repository->save($entry->setRawAttribute($this->fieldType->getField(), $content));
     }
     if (filemtime($path) < $entry->lastModified()->timestamp) {
         $this->dispatch(new PutFile($this->fieldType));
         $content = array_get($entry->getAttributes(), $this->fieldType->getField());
     }
     $this->dispatch(new ClearCache());
     return $content;
 }