public function classesFunction($context, ItemInterface $item, $hasChildren) { $classes = array('level_' . $item->getLevel(), 'type_' . $item->getType()); if ($item->isCurrent()) { $classes[] = 'active'; } if ($item->isTrail()) { $classes[] = 'trail'; } if ($hasChildren) { $classes[] = 'children'; } if ($this->linkIsVisibleFunction($context, $item)) { $classes[] = 'show-link'; } else { $classes[] = 'hide-link'; } if (isset($context['loop'])) { if ($context['loop']['first']) { $classes[] = 'first'; } if ($context['loop']['last']) { $classes[] = 'last'; } $classes[] = 'item_' . $context['loop']['index']; } /** @var EventDispatcherInterface $eventDispatcher */ $eventDispatcher = $GLOBALS['container']['event-dispatcher']; $event = new GenerateItemClassesEvent($item); $event->setClasses($classes); $eventDispatcher->dispatch(XNavigationEvents::GENERATE_ITEM_CLASSES, $event); return $event->getClasses(); }
/** * {@inheritdoc} */ public function matchItem(ItemInterface $item) { return $item->isCurrent(); }