Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php namespace Defr\FtlTheme\Page\Command;
- use Anomaly\FilesModule\Disk\Contract\DiskRepositoryInterface;
- use Anomaly\FilesModule\Folder\Contract\FolderRepositoryInterface;
- use Anomaly\PagesModule\Page\Contract\PageInterface;
- use Anomaly\Streams\Platform\Model\Pages\PagesEventPagesEntryModel;
- class CreateFolder
- {
- /**
- * Page model
- *
- * @var mixed
- */
- protected $page;
- /**
- * Create an instance of CreateFolder class
- *
- * @param PageInterface $page The page
- */
- public function __construct(PageInterface $page)
- {
- $this->page = $page;
- }
- /**
- * Handle the command
- *
- * @param FolderRepositoryInterface $folders The folders
- * @param DiskRepositoryInterface $disks The disks
- */
- public function handle(
- FolderRepositoryInterface $folders,
- DiskRepositoryInterface $disks
- )
- {
- if ($this->page->getEntry() instanceof PagesEventPagesEntryModel)
- {
- $disk = $disks->findBySlug('local');
- $slug = $this->page->getSlug();
- $title = $this->page->getTitle();
- $hash = md5($slug);
- $folders->create([
- 'en' => [
- 'name' => $title,
- 'description' => "A folder for {$title}.",
- ],
- 'slug' => $hash,
- 'disk' => $disk,
- 'allowed_types' => [
- 'png',
- 'jpeg',
- 'jpg',
- 'gif',
- 'svg',
- ],
- ]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement