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


PHP CRM_Core_BAO_RecurringEntity::quickAdd方法代码示例

本文整理汇总了PHP中CRM_Core_BAO_RecurringEntity::quickAdd方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_RecurringEntity::quickAdd方法的具体用法?PHP CRM_Core_BAO_RecurringEntity::quickAdd怎么用?PHP CRM_Core_BAO_RecurringEntity::quickAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_BAO_RecurringEntity的用法示例。


在下文中一共展示了CRM_Core_BAO_RecurringEntity::quickAdd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: triggerInsert

 /**
  * This function acts as a listener to dao->save,
  * and creates entries for linked entities in recurring entity table
  *
  * @param object $event
  *   An object of /Civi/Core/DAO/Event/PostUpdate containing dao object that was just inserted .
  *
  *
  * @return void
  */
 public static function triggerInsert($event)
 {
     $obj =& $event->object;
     if (!array_key_exists($obj->__table, self::$_linkedEntitiesInfo)) {
         return FALSE;
     }
     // if DB version is earlier than 4.6 skip any processing
     static $currentVer = NULL;
     if (!$currentVer) {
         $currentVer = CRM_Core_BAO_Domain::version();
     }
     if (version_compare($currentVer, '4.6.alpha1') < 0) {
         return;
     }
     static $processedEntities = array();
     if (empty($obj->id) || empty($obj->__table)) {
         return FALSE;
     }
     $key = "{$obj->__table}_{$obj->id}";
     if (array_key_exists($key, $processedEntities)) {
         // already being processed. Exit recursive calls.
         return NULL;
     }
     if (self::getStatus() == self::RUNNING) {
         // if recursion->generate() is doing some work, lets not intercept
         return NULL;
     }
     // mark being processed
     $processedEntities[$key] = 1;
     // get related entities for table being saved
     $hasaRecurringRecord = self::getParentFor($obj->id, $obj->__table);
     if (empty($hasaRecurringRecord)) {
         // check if its a linked entity
         if (array_key_exists($obj->__table, self::$_linkedEntitiesInfo) && !CRM_Utils_Array::value('is_multirecord', self::$_linkedEntitiesInfo[$obj->__table])) {
             $linkedDAO = new self::$_tableDAOMapper[$obj->__table]();
             $linkedDAO->id = $obj->id;
             if ($linkedDAO->find(TRUE)) {
                 $idCol = self::$_linkedEntitiesInfo[$obj->__table]['entity_id_col'];
                 $tableCol = self::$_linkedEntitiesInfo[$obj->__table]['entity_table_col'];
                 $pEntityID = $linkedDAO->{$idCol};
                 $pEntityTable = $linkedDAO->{$tableCol};
                 // find all parent recurring entity set
                 $pRepeatingEntities = self::getEntitiesFor($pEntityID, $pEntityTable);
                 if (!empty($pRepeatingEntities)) {
                     // for each parent entity in the set, find out a similar linked entity,
                     // if doesn't exist create one, and also create entries in recurring_entity table
                     foreach ($pRepeatingEntities as $key => $val) {
                         if (array_key_exists($key, $processedEntities)) {
                             // this graph is already being processed
                             return NULL;
                         }
                         $processedEntities[$key] = 1;
                     }
                     // start with first entry with just itself
                     CRM_Core_BAO_RecurringEntity::quickAdd($obj->id, $obj->id, $obj->__table);
                     foreach ($pRepeatingEntities as $key => $val) {
                         $rlinkedDAO = new self::$_tableDAOMapper[$obj->__table]();
                         $rlinkedDAO->{$idCol} = $val['id'];
                         $rlinkedDAO->{$tableCol} = $val['table'];
                         if ($rlinkedDAO->find(TRUE)) {
                             CRM_Core_BAO_RecurringEntity::quickAdd($obj->id, $rlinkedDAO->id, $obj->__table);
                         } else {
                             // linked entity doesn't exist. lets create them
                             $newCriteria = array($idCol => $val['id'], $tableCol => $val['table']);
                             $linkedObj = CRM_Core_BAO_RecurringEntity::copyCreateEntity($obj->__table, array('id' => $obj->id), $newCriteria, TRUE);
                             if ($linkedObj->id) {
                                 CRM_Core_BAO_RecurringEntity::quickAdd($obj->id, $linkedObj->id, $obj->__table);
                             }
                         }
                     }
                 }
             }
         }
     }
     // done with processing. lets unset static var.
     unset($processedEntities);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:87,代码来源:RecurringEntity.php


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