/**
  * 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));
     }
 }
 /**
  * Return the parsed content.
  *
  * @return string
  */
 public function __toString()
 {
     if (!$this->object->getValue()) {
         return '';
     }
     return $this->rendered();
 }
Пример #3
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;
 }
Пример #4
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()));
     }
 }
Пример #5
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 MarkdownFieldType $fieldType
  */
 public function onEntryDeleted(MarkdownFieldType $fieldType)
 {
     if (!$fieldType->getLocale()) {
         $this->dispatch(new DeleteDirectory($fieldType));
     }
 }