當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。