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


PHP DifferentialRevision::getRawRelations方法代码示例

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


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

示例1: alterRelationships

 private static function alterRelationships(DifferentialRevision $revision, array $stable_phids, array $rem_phids, array $add_phids, $reason_phid, $relation_type)
 {
     $rem_map = array_fill_keys($rem_phids, true);
     $add_map = array_fill_keys($add_phids, true);
     $seq_map = array_values($stable_phids);
     $seq_map = array_flip($seq_map);
     foreach ($rem_map as $phid => $ignored) {
         if (!isset($seq_map[$phid])) {
             $seq_map[$phid] = count($seq_map);
         }
     }
     foreach ($add_map as $phid => $ignored) {
         if (!isset($seq_map[$phid])) {
             $seq_map[$phid] = count($seq_map);
         }
     }
     $raw = $revision->getRawRelations($relation_type);
     $raw = ipull($raw, null, 'objectPHID');
     $sequence = count($seq_map);
     foreach ($raw as $phid => $ignored) {
         if (isset($seq_map[$phid])) {
             $raw[$phid]['sequence'] = $seq_map[$phid];
         } else {
             $raw[$phid]['sequence'] = $sequence++;
         }
     }
     $raw = isort($raw, 'sequence');
     foreach ($raw as $phid => $ignored) {
         if (isset($rem_map[$phid])) {
             unset($raw[$phid]);
         }
     }
     foreach ($add_phids as $add) {
         $reason = is_array($reason_phid) ? idx($reason_phid, $add) : $reason_phid;
         $raw[$add] = array('objectPHID' => $add, 'sequence' => idx($seq_map, $add, $sequence++), 'reasonPHID' => $reason);
     }
     $conn_w = $revision->establishConnection('w');
     $sql = array();
     foreach ($raw as $relation) {
         $sql[] = qsprintf($conn_w, '(%d, %s, %s, %d, %s)', $revision->getID(), $relation_type, $relation['objectPHID'], $relation['sequence'], $relation['reasonPHID']);
     }
     $conn_w->openTransaction();
     queryfx($conn_w, 'DELETE FROM %T WHERE revisionID = %d AND relation = %s', DifferentialRevision::RELATIONSHIP_TABLE, $revision->getID(), $relation_type);
     if ($sql) {
         queryfx($conn_w, 'INSERT INTO %T
         (revisionID, relation, objectPHID, sequence, reasonPHID)
       VALUES %Q', DifferentialRevision::RELATIONSHIP_TABLE, implode(', ', $sql));
     }
     $conn_w->saveTransaction();
     $revision->loadRelationships();
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:51,代码来源:DifferentialRevisionEditor.php


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