/**
  * 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()));
         }
     }
 }
 /**
  * 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()));
         }
     }
 }
Beispiel #3
0
 /**
  * Run the seeder.
  */
 public function run()
 {
     $this->pages->truncate();
     $type = $this->types->findBySlug('default');
     $welcome = (new PagesDefaultPagesEntryModel())->create(['content' => '<p>Welcome to PyroCMS!</p>']);
     $login = (new PagesDefaultPagesEntryModel())->create(['content' => '{{ form(\'login\').successMessage(\'You are now logged in.\')|raw }}']);
     $this->pages->create(['en' => ['title' => 'Welcome'], 'slug' => 'welcome', 'entry' => $welcome, 'type' => $type, 'enabled' => true, 'home' => true, 'theme_layout' => 'theme::layouts/default.twig'])->allowedRoles()->sync([]);
     $this->pages->create(['en' => ['title' => 'Login'], 'slug' => 'login', 'entry' => $login, 'type' => $type, 'enabled' => true, 'theme_layout' => 'theme::layouts/default.twig'])->allowedRoles()->sync([]);
 }
 /**
  * Handle the command.
  *
  * @param TypeRepositoryInterface $types
  * @param PageRepositoryInterface $pages
  */
 public function handle(TypeRepositoryInterface $types, PageRepositoryInterface $pages)
 {
     /* @var TypeInterface $type */
     $type = $types->find($this->type->getId());
     /* @var PageInterface $page */
     foreach ($type->getPages() as $page) {
         $pages->save($page->setAttribute('entry_type', $this->type->getEntryModelName()));
     }
 }
 /**
  * Resolve the page.
  *
  * @return Contract\PageInterface|null
  */
 public function resolve()
 {
     $action = $this->route->getAction();
     if ($id = array_get($action, 'anomaly.module.pages::page')) {
         return $this->pages->find($id);
     }
     if ($path = array_get($action, 'anomaly.module.pages::path')) {
         return $this->pages->findByPath($path);
     }
     return null;
 }
 /**
  * Redirect elsewhere.
  *
  * @param PageRepositoryInterface $pages
  * @param Redirector              $redirector
  * @param Route                   $route
  * @return \Illuminate\Http\RedirectResponse|void
  */
 public function redirect(PageRepositoryInterface $pages, Redirector $redirector, Route $route)
 {
     if ($to = array_get($route->getAction(), 'anomaly.module.pages::redirect')) {
         return $redirector->to($to, array_get($route->getAction(), 'status', 302));
     }
     /* @var PageInterface $page */
     if ($page = $pages->find(array_get($route->getAction(), 'anomaly.module.pages::page', 0))) {
         return $redirector->to($page->getPath(), array_get($route->getAction(), 'status', 302));
     }
     abort(404);
 }
Beispiel #7
0
 /**
  * Handle the command.
  *
  * @param PageRepositoryInterface $pages
  * @param ViewTemplate            $template
  * @return PageInterface|EloquentModel|null
  */
 public function handle(PageRepositoryInterface $pages, ViewTemplate $template)
 {
     if (is_null($this->identifier)) {
         $this->identifier = $template->get('page');
     }
     if (is_numeric($this->identifier)) {
         return $pages->find($this->identifier);
     }
     if (is_string($this->identifier)) {
         return $pages->findByPath($this->identifier);
     }
     if ($this->identifier instanceof PageInterface) {
         return $this->identifier;
     }
     if ($this->identifier instanceof PagePresenter) {
         return $this->identifier->getObject();
     }
     return null;
 }
Beispiel #8
0
 /**
  * Handle the command.
  */
 public function handle(PageRepositoryInterface $pages)
 {
     if ($this->page->isHome()) {
         $pages->update(['home' => false]);
     }
 }
 /**
  * Handle the command.
  *
  * @param PageRepositoryInterface $pages
  */
 public function handle(PageRepositoryInterface $pages)
 {
     foreach ($this->page->getChildren() as $page) {
         $pages->delete($page);
     }
 }
Beispiel #10
0
 /**
  * Run the seeder.
  */
 public function run()
 {
     $this->pages->truncate();
     $type = $this->types->findBySlug('default');
     $this->pages->create(['en' => ['title' => 'Welcome'], 'slug' => 'welcome', 'entry' => $type->getEntryModel()->create(['content' => '<p>Welcome to PyroCMS!</p>']), 'type' => $type, 'enabled' => true, 'home' => true, 'theme_layout' => 'theme::layouts/default.twig'])->allowedRoles()->sync([]);
 }
Beispiel #11
0
 /**
  * Handle the command.
  *
  * @param PageRepositoryInterface $pages
  */
 public function handle(PageRepositoryInterface $pages)
 {
     foreach ($this->type->pages()->onlyTrashed()->get() as $page) {
         $pages->restore($page);
     }
 }
 /**
  * Delete a page and go back.
  *
  * @param PageRepositoryInterface $pages
  * @param Authorizer              $authorizer
  * @param                         $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function delete(PageRepositoryInterface $pages, Authorizer $authorizer, $id)
 {
     $authorizer->authorize('anomaly.module.pages::pages.delete');
     $pages->delete($page = $pages->find($id));
     $page->entry->delete();
     return redirect()->back();
 }