Exemplo n.º 1
0
 /**
  * @return \Knp\Menu\MenuItem
  */
 public function configureMenu(\Knp\Menu\MenuItem $menu, $text = false)
 {
     $_menu = null;
     $options = array();
     $auth_object = null;
     if ($this->isRequestObject()) {
         $auth_object = $this->admin->getRouteObject();
     } else {
         if ($this->admin->tree && $this->admin->getTreeObjectId()) {
             $auth_object = $this->admin->getTreeObject();
         }
     }
     if (!$this->admin->auth($this->name, $auth_object)) {
         if ($this->isDeleteAction()) {
             return null;
         }
         if ($text) {
             if ($this->isRequestObject()) {
                 $label = $this->admin->string($auth_object);
             } else {
                 $label = $this->getActionLabel();
             }
             $_menu = $menu->addChild($label, $options);
         }
     } else {
         $label = null;
         if ($this->isRequestObject()) {
             $label = $this->getActionLabel($auth_object);
         } else {
             $label = $this->getActionLabel();
         }
         $options['uri'] = $this->path();
         $_menu = $menu->addChild($label, $options);
     }
     if ($_menu && $this->isRouteAction()) {
         $_menu->setCurrent(true);
     }
     return $_menu;
 }