/** * Creates a new Lavary\Menu\MenuItem instance. * * @param string $title * @param string $url * @param array $attributes * @param int $parent * @param \Lavary\Menu\Menu $builder * @return void */ public function __construct($builder, $id, $title, $options) { $this->builder = $builder; $this->id = $id; $this->title = $title; $this->nickname = camel_case($title); $this->attributes = $this->builder->extractAttributes($options); $this->parent = is_array($options) && isset($options['parent']) ? $options['parent'] : null; // Storing path options with each link instance. if (!is_array($options)) { $path = array('url' => $options); } elseif (isset($options['raw']) && $options['raw'] == true) { $path = null; } else { $path = array_only($options, array('url', 'route', 'action', 'secure')); } if (!is_null($path)) { $path['prefix'] = $this->builder->getLastGroupPrefix(); } $this->link = $path ? new Link($path) : null; // Activate the item if items's url matches the request uri if (true === $this->builder->conf('auto_activate')) { $this->checkActivationStatus(); } }
/** * Creates a new Lavary\Menu\MenuItem instance. * * @param string $title * @param string $url * @param array $attributes * @param int $parent * @param \Lavary\Menu\Menu $builder * @return void */ public function __construct($builder, $id, $title, $options) { $this->builder = $builder; $this->id = $id; $this->title = $title; $this->nickname = camel_case($title); $this->attributes = $this->builder->extractAttributes($options); $this->parent = is_array($options) && isset($options['parent']) ? $options['parent'] : null; // Storing path options with each link instance. if (!is_array($options)) { $path = array('url' => $options); } elseif (isset($options['raw']) && $options['raw'] == true) { $path = null; } else { $path = array_only($options, array('url', 'route', 'action', 'secure')); } if (!is_null($path)) { $path['prefix'] = $this->builder->getLastGroupPrefix(); } $this->link = $path ? new Link($path) : null; // If the item's URL is the same as request URI, // activate the item and it's parent nodes too. if (true === \Config::get('laravel-menu::options.auto_activate')) { if (\Request::url() == $this->url()) { $this->activate(); } } }