本文整理匯總了PHP中MenuItem::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP MenuItem::add方法的具體用法?PHP MenuItem::add怎麽用?PHP MenuItem::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MenuItem
的用法示例。
在下文中一共展示了MenuItem::add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: buildFromList
/**
* Build the menus.
*
* @param array $menus_list The list of menu information
* @param integer $parent The parent id to build.
*
* @return array
*/
protected function buildFromList($menus_list, $parent = 0)
{
$menus = array();
foreach ($menus_list as $menu) {
//Process only if the menu was not already processed
//and it belongs to the parent id we are building.
if (!$this->isProcessed($menu) && $menu['parent_id'] == $parent) {
//First get the submenus
$children = $this->buildFromList($menus_list, $menu['id']);
$item = new MenuItem($menu['name'], $menu['url']);
foreach ($children as $child) {
$item->add($child);
}
$menus[] = $item;
//Update the status of the current item.
$this->setProcessed($menu);
}
}
return $menus;
}
示例2: v1_6_0
/**
* v1.6.0 : Add the menu item 'user.login'
*/
public function v1_6_0()
{
MenuItem::add(array('plugin' => 'main', 'name' => 'login', 'labelKey' => 'main.login-menu-title', 'icon' => 'sign-in', 'action' => 'login', 'target' => 'dialog'));
}