/**
  * 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));
     }
 }
Exemple #2
0
 /**
  * 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;
 }
Exemple #3
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()));
     }
 }
 /**
  * Return the parsed content.
  *
  * @return string
  */
 public function __toString()
 {
     if (!$this->object->getValue()) {
         return '';
     }
     if (in_array($this->object->getFileExtension(), ['html', 'twig'])) {
         return $this->rendered();
     } else {
         return $this->content();
     }
 }
 /**
  * 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 EditorFieldType $fieldType
  */
 public function onEntryDeleted(EditorFieldType $fieldType)
 {
     if (!$fieldType->getLocale()) {
         $this->dispatch(new DeleteDirectory($fieldType));
     }
 }