/** * Normalize the navigation input. * * @param ControlPanelBuilder $builder */ public function normalize(ControlPanelBuilder $builder) { $links = $builder->getNavigation(); foreach ($links as $path => &$link) { /** * If the link is a string * then it must be in the * $path => $title format. */ if (is_string($link)) { $link = ['href' => $path]; } /** * Make sure we have attributes. */ $link['attributes'] = array_get($link, 'attributes', []); /** * Move the HREF into attributes. */ if (isset($link['href'])) { $link['attributes']['href'] = array_pull($link, 'href'); } /** * Move all data-* keys * to attributes. */ foreach ($link as $attribute => $value) { if (str_is('data-*', $attribute)) { array_set($link, 'attributes.' . $attribute, array_pull($link, $attribute)); } } /** * Make sure the HREF and data-HREF are absolute. */ if (isset($link['attributes']['href']) && is_string($link['attributes']['href']) && !starts_with($link['attributes']['href'], 'http')) { $link['attributes']['href'] = url($link['attributes']['href']); } } $builder->setNavigation($links); }
/** * Evaluate the navigation. * * @param ControlPanelBuilder $builder */ public function evaluate(ControlPanelBuilder $builder) { $this->evaluator->evaluate($builder->getNavigation(), compact('builder')); }
/** * Resolve the navigation. * * @param ControlPanelBuilder $builder */ public function resolve(ControlPanelBuilder $builder) { $this->resolver->resolve($builder->getNavigation(), compact('builder')); }