Пример #1
0
 /**
  * Handle the command.
  *
  * @return \Anomaly\NavigationModule\Link\LinkCollection|mixed|null
  */
 public function handle()
 {
     if (!$this->menu) {
         $this->menu = $this->dispatch(new GetMenu($this->options->get('menu')));
     }
     if ($this->menu) {
         $links = $this->menu->getLinks();
     } else {
         $links = $this->options->get('links');
     }
     if (!$links) {
         return null;
     }
     if ($root = $this->options->get('root')) {
         if ($link = $this->dispatch(new GetParentLink($root, $links))) {
             $this->options->put('parent', $link);
         }
     }
     // Remove restricted for security purposes.
     $this->dispatch(new RemoveRestrictedLinks($links));
     // Set the relationships manually.
     $this->dispatch(new SetParentRelations($links));
     $this->dispatch(new SetChildrenRelations($links));
     // Flag appropriate links.
     $this->dispatch(new SetCurrentLink($links));
     $this->dispatch(new SetActiveLinks($links));
     return $links;
 }
 /**
  * Return links belonging to
  * the provided menu.
  *
  * @param MenuInterface $menu
  * @return LinkCollection
  */
 public function findAllByMenu(MenuInterface $menu)
 {
     return $this->model->where('menu_id', $menu->getId())->get();
 }
 /**
  * Handle the command.
  *
  * @param LinkRepositoryInterface $links
  */
 public function handle(LinkRepositoryInterface $links)
 {
     foreach ($this->menu->getLinks() as $link) {
         $links->delete($link);
     }
 }