Example #1
0
 /**
  * Set node as current
  * @param NavigationNode node
  */
 public function setCurrent(NavigationNode $node)
 {
     if (isset($this->current)) {
         $this->current->setCurrentFlag(false);
     }
     $this->current = $node->setCurrentFlag(true);
 }
 private function build(NavigationNode $node, $entities)
 {
     foreach ($entities as $key => $entity) {
         if ($entity->getOwnerId() == 0 && $node->getParent() == null) {
             $node->addFromItem($entity);
             unset($entities[$key]);
             continue;
         }
         if ($node->getItem() == null) {
             continue;
         }
         if ($entity->getOwnerId() == $node->getItem()->getId()) {
             $node->addFromItem($entity);
             unset($entities[$key]);
         }
     }
     if (count($entities) > 0) {
         foreach ($node->getChildren() as $child) {
             $child = $this->build($child, $entities);
         }
     }
     return $node;
 }
 /**
  * Defines how to sort item's childs
  * @param int $flag
  * @param bool $deep whether or not to apply sort to item's children
  * @return NavigationNode
  */
 public function sortBy($flag, $deep = TRUE)
 {
     return $this->root->sortBy($flag, $deep);
 }