コード例 #1
0
 /**
  * Sync a file.
  *
  * @param Directory     $resource
  * @param DiskInterface $disk
  * @return null|FolderInterface
  */
 public function sync(Directory $resource, DiskInterface $disk)
 {
     $path = $resource->getPath();
     if ($path === '.') {
         return null;
     }
     if (!($folder = $this->folders->findBySlug($path))) {
         $folder = $this->folders->create(['name' => $path, 'disk_id' => $disk->getId()]);
     }
     return $folder;
 }
コード例 #2
0
 /**
  * Sync the files folder.
  *
  * @param File          $resource
  * @param DiskInterface $disk
  * @return null|FolderInterface
  */
 protected function syncFolder(File $resource, DiskInterface $disk)
 {
     $path = dirname($resource->getPath());
     if ($path === '.') {
         return null;
     }
     /* @var FolderInterface|null $parent */
     $parent = null;
     $folder = null;
     foreach (explode('/', $path) as $name) {
         if (!($folder = $this->folders->findBySlug($name))) {
             $folder = $this->folders->create(['name' => $name, 'disk_id' => $disk->getId(), 'parent_id' => $parent ? $parent->getId() : null]);
         }
         $parent = $folder;
     }
     return $folder;
 }
コード例 #3
0
 /**
  * Find a folder by it's name and parent folder.
  *
  * @param                 $name
  * @param DiskInterface   $disk
  * @param FolderInterface $parent
  * @return null|FolderInterface
  */
 public function findByName($name, DiskInterface $disk, FolderInterface $parent = null)
 {
     return $this->model->where('name', $name)->where('disk_id', $disk->getId())->where('parent_id', $parent ? $parent->getId() : null)->first();
 }
コード例 #4
0
ファイル: DiskPresenter.php プロジェクト: ramcda/files-module
 /**
  * Return the view link.
  *
  * @return string
  */
 public function viewLink()
 {
     return app('html')->link(implode('/', array_filter(['admin', 'files', 'browser', $this->object->getSlug()])), $this->object->getName());
 }
コード例 #5
0
 /**
  * Find a file by it's name.
  *
  * @param                 $name
  * @param DiskInterface   $disk
  * @param FolderInterface $folder
  * @return null|FileInterface
  */
 public function findByName($name, DiskInterface $disk, FolderInterface $folder = null)
 {
     return $this->model->where('name', $name)->where('disk_id', $disk->getId())->where('folder_id', $folder ? $folder->getId() : null)->first();
 }
コード例 #6
0
 /**
  * Handle the command.
  *
  * @param BreadcrumbCollection $breadcrumbs
  */
 public function handle(BreadcrumbCollection $breadcrumbs)
 {
     $breadcrumbs->add($this->disk->getName(), 'admin/files/browser/' . $this->disk->getSlug());
 }
コード例 #7
0
 /**
  * Register the disk.
  *
  * @param DiskInterface $disk
  */
 public function register(DiskInterface $disk)
 {
     if ($adapter = $disk->getAdapter()) {
         $this->container->call(substr(get_class($adapter), 0, -9) . 'Loader@load', compact('disk', 'adapter'));
     }
 }
コード例 #8
0
 /**
  * Handle the command.
  *
  * @param FolderRepositoryInterface $folders
  */
 public function handle(FolderRepositoryInterface $folders)
 {
     foreach ($this->disk->getFolders() as $folder) {
         $folders->forceDelete($folder);
     }
 }