Exemplo n.º 1
0
 /**
  * Handle the command.
  *
  * @param StreamRepositoryInterface $streams
  */
 public function handle(StreamRepositoryInterface $streams)
 {
     if (!$this->folder->isForceDeleting()) {
         return;
     }
     $streams->delete($streams->findBySlugAndNamespace($this->folder->getSlug(), 'files'));
 }
Exemplo n.º 2
0
 /**
  * Handle the command.
  *
  * @param MountManager $manager
  */
 public function handle(MountManager $manager)
 {
     if (!($disk = $this->folder->getDisk())) {
         return;
     }
     if (!$this->folder->isForceDeleting()) {
         return;
     }
     $manager->deleteDir($disk->getSlug() . '://' . $this->folder->getSlug());
 }
Exemplo n.º 3
0
 /**
  * Upload a file.
  *
  * @param UploadedFile    $file
  * @param FolderInterface $folder
  * @return bool|FileInterface
  */
 public function upload(UploadedFile $file, FolderInterface $folder)
 {
     $rules = 'required';
     if ($allowed = $folder->getAllowedTypes()) {
         $rules .= '|mimes:' . implode(',', $allowed);
     }
     $validation = $this->validator->make(['file' => $file], ['file' => $rules]);
     if (!$validation->passes()) {
         return false;
     }
     $disk = $folder->getDisk();
     /* @var FileInterface $entry */
     $entry = $this->manager->put($disk->getSlug() . '://' . $folder->getSlug() . '/' . $file->getClientOriginalName(), file_get_contents($file->getRealPath()));
     if (in_array($entry->getExtension(), $this->config->get('anomaly.module.files::mimes.types.image'))) {
         $size = getimagesize($file->getRealPath());
         $this->files->save($entry->setAttribute('width', $size[0])->setAttribute('height', $size[1]));
     }
     return $entry;
 }
Exemplo n.º 4
0
 /**
  * Handle the command.
  *
  * @param StreamRepositoryInterface $streams
  * @param Repository                $config
  */
 public function handle(StreamRepositoryInterface $streams, Repository $config)
 {
     $streams->create([$config->get('app.fallback_locale') => ['name' => $this->folder->getName(), 'description' => $this->folder->getDescription()], 'namespace' => 'files', 'slug' => $this->folder->getSlug(), 'translatable' => true, 'locked' => false]);
 }
Exemplo n.º 5
0
 /**
  * Handle the command.
  *
  * @param StreamRepositoryInterface $streams
  * @return \Anomaly\Streams\Platform\Stream\Contract\StreamInterface|null
  */
 public function handle(StreamRepositoryInterface $streams)
 {
     return $streams->findBySlugAndNamespace($this->folder->getSlug(), 'files');
 }
Exemplo n.º 6
0
 /**
  * Handle the command.
  *
  * @param StreamRepositoryInterface $streams
  */
 public function handle(StreamRepositoryInterface $streams)
 {
     $streams->delete($streams->findBySlugAndNamespace($this->folder->getSlug() . '_files', 'files'));
 }
Exemplo n.º 7
0
 /**
  * Handle the command.
  *
  * @param MountManager $manager
  */
 public function handle(MountManager $manager)
 {
     $disk = $this->folder->getDisk();
     $manager->deleteDir($disk->getSlug() . '://' . $this->folder->getSlug());
 }