$this->make(self::_STANDARD_PREFIX . '_' . $item->getName(), function ($menu) use ($item) {
$this->makeStandardMenu($menu, $item);
});
+ $this->make('mobile_' . $item->getName(), function ($menu) use ($item) {
+ $this->makeMobileMenu($menu, $item);
+ });
foreach ($this->_registeredMenuMakers as $name => $registeredMenuMaker) {
$this->make($name . '_' . $item->getName(), function ($menu) use ($item, $registeredMenuMaker) {
call_user_func($registeredMenuMaker, $menu, $item);
}
}
+ /**
+ * @param $menu Menu
+ * @param $item Item
+ */
+ public function makeMobileMenu($menu, $item, $depth = 3)
+ {
+ if ($depth == 0) {
+ return;
+ }
+ foreach ($item->getChildren() as $child) {
+ if ($child->isNavigable()) {
+ $parent = $menu->add($child->getTitle(), $child->getHref());
+ } else {
+ $parent = $menu->raw('<span>'.$child->getTitle().'</span>');
+ }
+ $this->makeMobileMenu($parent, $child, $depth - 1);
+ }
+ }
+
/**
* @param $nav Item
* @param $menu \Lavary\Menu\Item
return $this->_template;
}
+ public function isNavigable()
+ {
+ $template = $this->getTemplate();
+ if (!$template) {
+ return true;
+ }
+ if ($template == 'first_redirection' || $template == 'internal_redirection' || $template == 'redirection' || $this->isVirtual()) {
+ return false;
+ }
+ return parent::isNavigable();
+ }
+
public function getHref()
{
$template = $this->getTemplate();
{
$response = $next($request);
- if (strpos($request->getPathInfo(), '/admin/') === 0) {
- return $response;
- }
// Apply logic differently based on the nature of $response.
if ($response instanceof Renderable) {