public function createItem($itemArray) { if (is_array($itemArray)) { if (array_key_exists('text', $itemArray) && array_key_exists('url', $itemArray)) { $navItem = new sfNavBuilderItem(); $navItem->setDisplayName($itemArray['text'])->setUrl(url_for($itemArray['url'])); if (array_key_exists('class', $itemArray)) { $navItem->setClass($itemArray['class']); } if (array_key_exists('activate_when', $itemArray)) { $navItem->addActivateWhen($itemArray['activate_when']); } if (array_key_exists('credentials', $itemArray)) { $navItem->addCredentialRules($itemArray['credentials']); } if (array_key_exists('childrens', $itemArray)) { foreach ($itemArray['childrens'] as $childArray) { $childMenu = $this->createItem($childArray); if ($childMenu) { $navItem->addChild($childMenu); } } } return $navItem; } } }
/** * Sets this item as the parent of the supplied item allowing hierarchy to * be created in the menu * @param sfNavBuilderItem $i An item to set as the parent of this item * @return sfNavBuilderItem $this The current sfNavBuilderItem instance * @see addChild() for alternative hierarchy creation */ public function setParent(sfNavBuilderItem $i) { $i->addChild($this); return $this; }