/** * Creates a menu item link element * * @param Menu $menu * * @return string */ public function createLink(Menu $menu) { if ($menu->getIcon() && strpos($menu->getIcon(), '.') === false) { return sprintf('<a href="%s"%s><i aria-hidden="true" class="icon-%s"></i>%s</a>', $menu->getUrl() ?: '#', $this->getAttributes(), $menu->getIcon(), $this->getView()->escape($menu->getTitle())); } return sprintf('<a href="%s"%s>%s%s<span></span></a>', $menu->getUrl() ?: '#', $this->getAttributes(), $menu->getIcon() ? '<img aria-hidden="true" src="' . Url::fromPath($menu->getIcon()) . '" class="icon" /> ' : '', $this->getView()->escape($menu->getTitle())); }
/** * Whether this Menu conflicts with the given Menu object * * @param Menu $menu * * @return bool */ public function conflictsWith(Menu $menu) { if ($menu->getUrl() === null || $this->getUrl() === null) { return false; } return $menu->getUrl() !== $this->getUrl(); }
/** * Return whether the current request url references the child's url * * @param Menu $child The menu's child to check * * @return bool */ protected function isActive(Menu $child) { if (!$this->url) { return false; } if (!($childUrl = $child->getUrl())) { return false; } return $this->url && $this->url->matches($childUrl); }