Exemplo n.º 1
0
 public function addCurrent(ItemInterface $menu)
 {
     $currentRoute = $this->stack->getMasterRequest()->get('_route');
     $route = $this->menu[$menu->getName()]['route'];
     if ($currentRoute == $route) {
         $menu->setCurrent(true);
     }
 }
Exemplo n.º 2
0
 /**
  * Checks whether an item is current.
  *
  * If the voter is not able to determine a result,
  * it should return null to let other voters do the job.
  *
  * @param ItemInterface $item
  *
  * @return boolean|null
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getExtra('link', false) && $this->parentControl) {
         $presenter = $this->parentControl->getPresenter(true);
         $item->setCurrent(call_user_func_array(array($presenter, 'isLinkCurrent'), $item->getExtra('link')));
         return $item->isCurrent();
     }
     return null;
 }
Exemplo n.º 3
0
 public function isAncestor(ItemInterface $item, $depth = null)
 {
     if (0 === $depth) {
         return false;
     }
     $childDepth = null === $depth ? null : $depth - 1;
     foreach ($item->getChildren() as $child) {
         if ($this->isCurrent($child) || $this->isAncestor($child, $childDepth)) {
             $item->setCurrent(true);
             return true;
         }
     }
     return false;
 }
Exemplo n.º 4
0
 protected function setCurrentItem(ItemInterface $menu)
 {
     $menu->setCurrent($this->container->get('request')->getPathInfo());
 }