/**
  * Handle the command.
  *
  * @param Filesystem $files
  */
 public function handle(Filesystem $files)
 {
     $path = $this->fieldType->getStoragePath();
     if ($path && $files->isDirectory(dirname($path))) {
         $files->deleteDirectory(dirname($path));
     }
 }
 /**
  * Handle the command.
  *
  * @param Filesystem $files
  */
 public function handle(Filesystem $files)
 {
     $path = $this->fieldType->getStoragePath();
     if ($path && $files->isFile($path)) {
         return $files->get($path);
     }
     return null;
 }
 /**
  * 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()));
     }
 }
 /**
  * Return the parsed content.
  *
  * @return string
  */
 public function __toString()
 {
     if (!$this->object->getValue()) {
         return '';
     }
     return $this->rendered();
 }
 /**
  * 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;
 }
Example #6
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;
 }
 /**
  * Fired after an entry is deleted.
  *
  * @param WysiwygFieldType $fieldType
  */
 public function onEntryDeleted(WysiwygFieldType $fieldType)
 {
     if (!$fieldType->getLocale()) {
         $this->dispatch(new DeleteDirectory($fieldType));
     }
 }