/** * Build a level of menu * * @param array $config * @param Lavary\Menu\Builder $menu * @param string|null $namespace * @return void */ protected function build(array $config, Builder $menu, $namespace = null) { foreach ($config as $key => $value) { $route = null; if (isset($value['route'])) { $route = ['route' => $value['route']]; } if (isset($value['url'])) { $route = $value['url']; } if ($namespace) { $menu->get(strtolower($namespace))->add($key, $route)->data('public', $value['public']); } else { $menu->add($key, $route)->data('public', $value['public']); } if (isset($value['children'])) { $this->build($value['children'], $menu, $key); } } }
/** * Make the item active * * @return Lavary\Menu\Item */ public function active($pattern = null) { if (!is_null($pattern)) { $pattern = ltrim(preg_replace('/\\/\\*/', '(/.*)?', $pattern), '/'); if (preg_match("@^{$pattern}\\z@", \Request::path())) { $this->activate(); } return $this; } $this->attributes['class'] = Builder::formatGroupClass(array('class' => $this->builder->conf('active_class')), $this->attributes); return $this; }