/** * Handle the command. */ public function handle(ViewTemplate $template) { /* @var PageInterface $page */ if (!($page = $template->get('page'))) { return; } /* @var PageInterface $current */ $current = $this->pages->find($page->getId()); $current->setCurrent(true); }
/** * 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; }