当前位置: 首页>>代码示例>>PHP>>正文


PHP MenuItem::persist方法代码示例

本文整理汇总了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);
         }
     }
 }
开发者ID:jakedorst,项目名称:ch3-dev-preview,代码行数:31,代码来源:Enumeration.php

示例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);
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:29,代码来源:MenuManagerController.php


注:本文中的MenuItem::persist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。