本文整理汇总了PHP中MenuItem::persist方法的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem::persist方法的具体用法?PHP MenuItem::persist怎么用?PHP MenuItem::persist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItem
的用法示例。
在下文中一共展示了MenuItem::persist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _generateMenuEnumerationTree
protected static function _generateMenuEnumerationTree(Enumeration $enumeration)
{
static $enumerationIds = array();
$enumerationId = $enumeration->enumerationId;
$enumerationsClosure = new EnumerationsClosure();
$descendants = $enumerationsClosure->getEnumerationTreeById($enumerationId);
$displayOrder = 0;
foreach ($descendants as $enum) {
if (isset($enumerationIds[$enum->enumerationId])) {
continue;
}
$enumerationIds[$enum->enumerationId] = true;
$displayOrder += 10;
$menu = new MenuItem();
$menu->siteSection = 'All';
$menu->type = 'freeform';
$menu->active = 1;
$menu->title = $enum->name;
//$menu->displayOrder = $displayOrder;
$menu->displayOrder = $enum->enumerationId;
// temporarily set displayOrder using the enumerationId
$menu->parentId = $enumerationId;
$menu->persist();
$enum->ormId = $menu->menuId;
$enum->persist();
if ($enumerationId != $enum->enumerationId) {
// prevents infinite loop
self::_generateMenuEnumerationTree($enum);
}
}
}
示例2: ajaxMoveMenuItemAction
/**
* Move menu
*/
public function ajaxMoveMenuItemAction()
{
$idFrom = (int) $this->_getParam('idFrom');
$idTo = (int) $this->_getParam('idTo');
$idBefore = (int) $this->_getParam('idBefore');
if ($idTo == 'menu') {
$idTo = 0;
}
$menuItem = new MenuItem();
$menuItem->menuId = $idFrom;
$menuItem->populate();
if ($idBefore > 0) {
//this is the sibling reorder case
$beforeMenuItem = new MenuItem();
$beforeMenuItem->menuId = $idBefore;
$beforeMenuItem->populate();
$menuItem->updateDisplayOrder($beforeMenuItem->displayOrder);
} else {
//this is the hierarchy level move case
$menuItem->parentId = $idTo;
$menuItem->persist();
}
$json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$json->suppressExit = true;
$json->direct(true);
}