/**
  * populate
  *
  * Populate the the navigation container with the provided
  * data. This will be recursivly added to the container
  * 
  * @param  \Zend_Navigation_Container $navigation The navigation container
  * @param  mixed(array|ArrayCollection)           $data       The children to add
  * @return \Zend_Navigation_Container
  */
 protected function populate(\Zend_Navigation_Container $navigation, $data)
 {
     foreach ($data as $page) {
         $mvc = new \Zend_Navigation_Page_Mvc(array('label' => $page->getTitle(), 'module' => $page->getModule(), 'controller' => $page->getController(), 'action' => $page->getAction(), 'route' => $page->getRoute()));
         if ($page->hasChildren()) {
             $this->populate($mvc, $page->getChildren());
         }
         $navigation->addPage($mvc);
     }
     return $navigation;
 }
Exemplo n.º 2
0
 /**
  * Sets parent container
  *
  * @param  Zend_Navigation_Container $parent  [optional] new parent to set.
  *                                            Default is null which will set
  *                                            no parent.
  * @return Zend_Navigation_Page               fluent interface, returns self
  */
 public function setParent(Zend_Navigation_Container $parent = null)
 {
     if ($parent === $this) {
         // require_once 'Zend/Navigation/Exception.php';
         throw new Zend_Navigation_Exception('A page cannot have itself as a parent');
     }
     // return if the given parent already is parent
     if ($parent === $this->_parent) {
         return $this;
     }
     // remove from old parent
     if (null !== $this->_parent) {
         $this->_parent->removePage($this);
     }
     // set new parent
     $this->_parent = $parent;
     // add to parent if page and not already a child
     if (null !== $this->_parent && !$this->_parent->hasPage($this, false)) {
         $this->_parent->addPage($this);
     }
     return $this;
 }
Exemplo n.º 3
0
 public function addPage($page)
 {
     parent::addPage($page);
     $this->_pages = array();
 }
Exemplo n.º 4
0
 private function addChildren(Zend_Navigation_Container $nav, SysModule $module)
 {
     $children = $module->getChildren();
     /* @var $module SysModule */
     foreach ($children as $module) {
         $page = $this->createPage($module);
         if ($module->hasChildren()) {
             if ($module->countChildren() > 1) {
                 $this->addChildren($page, $module);
             } else {
                 /** @var SysModule $child */
                 $child = $module->getFirstChild();
                 $page = $this->createPage($child);
             }
         }
         $nav->addPage($page);
         if ($page->isActive()) {
             $nav->setActive(true);
         }
     }
 }
Exemplo n.º 5
0
 /**
  * @deprecated
  * @param \Zend_Navigation_Container $menu
  * @param string $label
  * @param array $arg_array
  */
 public static function addUrl2Page(\Zend_Navigation_Container $menu, $label, $arg_array = null)
 {
     $args = array_slice(func_get_args(), 2);
     $menu->addPage(self::url($args)->toPage($label));
 }