/** * 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; }
/** * Handle the command. * * @param LinkRepositoryInterface $links */ public function handle(LinkRepositoryInterface $links) { foreach ($this->menu->getLinks() as $link) { $links->delete($link); } }