/** * Handle the command. * * @param EntryFormBuilder $builder */ public function handle(EntryFormBuilder $builder) { $type = $this->page->getType(); $builder->setModel($type->getEntryModelName()); $builder->setEntry($this->page->getEntryId()); $this->builder->addForm('entry', $builder); }
/** * Authorize the page. * * @param PageInterface $page */ public function authorize(PageInterface $page) { /* @var UserInterface $user */ $user = $this->guard->user(); /** * If the page is not enabled and we * are not logged in then 404. */ if (!$page->isEnabled() && !$user) { abort(404); } /** * If the page is not enabled and we are * logged in then make sure we have permission. */ if (!$page->isEnabled()) { $this->authorizer->authorize('anomaly.module.pages::view_drafts'); } /** * If the page is restricted to specific * roles then make sure our user is one of them. */ $allowed = $page->getAllowedRoles(); if (!$allowed->isEmpty() && (!$user || !$user->hasAnyRole($allowed))) { $page->setResponse($this->response->redirectTo('login')); } }
/** * Load page data to the template. * * @param PageInterface $page */ public function load(PageInterface $page) { $this->template->set('title', $page->getTitle()); $this->template->set('meta_title', $page->getMetaTitle()); $this->template->set('meta_keywords', $page->getMetaKeywords()); $this->template->set('meta_description', $page->getMetaDescription()); }
/** * Load the parent breadcrumbs. * * @param PageInterface $page * @param array $breadcrumbs */ protected function loadParent(PageInterface $page, array &$breadcrumbs) { if ($parent = $page->getParent()) { $breadcrumbs[$parent->getTitle()] = $parent->getPath(); $this->loadParent($parent, $breadcrumbs); } }
/** * Make the view content. * * @param PageInterface $page */ public function make(PageInterface $page) { $type = $page->getType(); /* @var EditorFieldType $layout */ $layout = $type->getFieldType('layout'); $page->setContent($this->view->make($layout->getViewPath(), compact('page'))->render()); }
/** * Handle the command. * * @param PageRepositoryInterface $pages */ public function handle(PageRepositoryInterface $pages) { foreach ($this->page->getChildren() as $page) { if ($page instanceof PageInterface && $page->isEnabled()) { $pages->save($page->setAttribute('path', $this->page->getPath() . '/' . $page->getSlug())); } } }
/** * Catch calls to fields on * the page's related entry. * * @param string $key * @return mixed */ public function __get($key) { $entry = $this->object->getEntry(); if ($entry->hasField($key)) { return (new Decorator())->decorate($entry)->{$key}; } return parent::__get($key); }
/** * Handle the command. * * @param PageRepositoryInterface $pages */ public function handle(PageRepositoryInterface $pages) { /* @var PageInterface $page */ foreach ($this->page->getChildren() as $page) { if ($page->isEnabled()) { $pages->save($page->setPath($this->page->getPath() . '/' . $page->getSlug())); } } }
/** * Add the page and page type assets. * * @param PageInterface $page * @throws \Exception */ public function add(PageInterface $page) { /* @var EditorFieldTypePresenter $js */ /* @var EditorFieldTypePresenter $css */ $js = $page->getFieldTypePresenter('js'); $css = $page->getFieldTypePresenter('css'); $this->asset->add('styles.css', $css->path()); $this->asset->add('scripts.js', $js->path()); $type = $page->getType(); $js = $type->getFieldTypePresenter('js'); $css = $type->getFieldTypePresenter('css'); $this->asset->add('styles.css', $css->path()); $this->asset->add('scripts.js', $js->path()); }
/** * Authorize the page. * * @param PageInterface $page */ public function authorize(PageInterface $page) { /* @var UserInterface $user */ $user = $this->guard->user(); /** * If the page is not enabled and we * are not logged in then 404. */ if (!$page->isEnabled() && !$user) { abort(404); } /** * If the page is not enabled and we are * logged in then make sure we have permission. */ if (!$page->isEnabled() && !$this->authorizer->authorize('anomaly.module.pages::view_drafts')) { abort(403); } /** * If the page is restricted to specific * roles then make sure our user is one of them. */ $allowed = $page->getAllowedRoles(); /** * If there is a guest role and * there IS a user then this * page can NOT display. */ if ($allowed->has('guest') && $user && !$user->isAdmin()) { abort(403); } // No longer needed. $allowed->forget('guest'); /** * Check the roles against the * user if there are any. */ if (!$allowed->isEmpty() && (!$user || !$user->hasAnyRole($allowed) && !$user->isAdmin())) { $page->setResponse($this->response->redirectGuest('login')); } }
/** * Handle the command. */ public function handle() { if (!$this->page->isEnabled()) { $path = 'pages/preview/' . $this->page->getStrId(); } else { if ($parent = $this->page->getParent()) { $path = $parent->getPath() . '/' . $this->page->getSlug(); } elseif ($this->page->isHome()) { $path = '/'; } else { $path = '/' . $this->page->getSlug(); } } $this->page->setAttribute('path', $path); }
/** * Handle the command. */ public function handle() { if ($parent = $this->page->getParent()) { if ($parent->isHome()) { return $parent->getSlug() . '/' . $this->page->getSlug(); } else { return $parent->getPath() . '/' . $this->page->getSlug(); } } elseif ($this->page->isHome()) { return '/'; } else { return '/' . $this->page->getSlug(); } }
/** * Handle the command. */ public function handle(PageRepositoryInterface $pages) { if ($this->page->isHome()) { $pages->update(['home' => false]); } }
/** * Make the page response. * * @param PageInterface $page */ public function make(PageInterface $page) { if (!$page->getResponse()) { $page->setResponse($this->response->view('anomaly.module.pages::page', ['page' => $page, 'content' => $page->getContent()])); } }
/** * Handle the command. */ public function handle() { if (!$this->page->getStrId()) { $this->page->str_id = str_random(24); } }
/** * Handle the command. * * @param PageRepositoryInterface $pages */ public function handle(PageRepositoryInterface $pages) { foreach ($this->page->getChildren() as $page) { $pages->delete($page); } }
/** * Handle the command. * * @param PageRepositoryInterface $pages */ public function handle(EloquentRepositoryInterface $repository) { if ($entry = $this->page->getEntry()) { $repository->delete($entry); } }
/** * Handle the command. * * @param PageFormBuilder $builder */ public function handle(PageFormBuilder $builder) { $builder->setEntry($this->page->getId()); $this->builder->addForm('page', $builder); }