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


PHP DifferentialDiff::setDescription方法代码示例

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


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

示例1: applyFieldEdit

 protected function applyFieldEdit(ConduitAPIRequest $request, DifferentialRevision $revision, DifferentialDiff $diff, array $fields, $message)
 {
     $viewer = $request->getUser();
     $field_list = PhabricatorCustomField::getObjectFields($revision, DifferentialCustomField::ROLE_COMMITMESSAGEEDIT);
     $field_list->setViewer($viewer)->readFieldsFromStorage($revision);
     $field_map = mpull($field_list->getFields(), null, 'getFieldKeyForConduit');
     $xactions = array();
     $xactions[] = id(new DifferentialTransaction())->setTransactionType(DifferentialTransaction::TYPE_UPDATE)->setNewValue($diff->getPHID());
     $values = $request->getValue('fields', array());
     foreach ($values as $key => $value) {
         $field = idx($field_map, $key);
         if (!$field) {
             // NOTE: We're just ignoring fields we don't know about. This isn't
             // ideal, but the way the workflow currently works involves us getting
             // several read-only fields, like the revision ID field, which we should
             // just skip.
             continue;
         }
         $role = PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS;
         if (!$field->shouldEnableForRole($role)) {
             continue;
         }
         // TODO: This is fairly similar to PhabricatorCustomField's
         // buildFieldTransactionsFromRequest() method, but that's currently not
         // easy to reuse.
         $transaction_type = $field->getApplicationTransactionType();
         $xaction = id(new DifferentialTransaction())->setTransactionType($transaction_type);
         if ($transaction_type == PhabricatorTransactions::TYPE_CUSTOMFIELD) {
             // For TYPE_CUSTOMFIELD transactions only, we provide the old value
             // as an input.
             $old_value = $field->getOldValueForApplicationTransactions();
             $xaction->setOldValue($old_value);
         }
         // The transaction itself will be validated so this is somewhat
         // redundant, but this validator will sometimes give us a better error
         // message or a better reaction to a bad value type.
         $field->validateCommitMessageValue($value);
         $field->readValueFromCommitMessage($value);
         $xaction->setNewValue($field->getNewValueForApplicationTransactions());
         if ($transaction_type == PhabricatorTransactions::TYPE_CUSTOMFIELD) {
             // For TYPE_CUSTOMFIELD transactions, add the field key in metadata.
             $xaction->setMetadataValue('customfield:key', $field->getFieldKey());
         }
         $metadata = $field->getApplicationTransactionMetadata();
         foreach ($metadata as $meta_key => $meta_value) {
             $xaction->setMetadataValue($meta_key, $meta_value);
         }
         $xactions[] = $xaction;
     }
     $message = $request->getValue('message');
     if (strlen($message)) {
         // This is a little awkward, and should maybe move inside the transaction
         // editor. It largely exists for legacy reasons.
         $first_line = head(phutil_split_lines($message, false));
         $diff->setDescription($first_line);
         $diff->save();
         $xactions[] = id(new DifferentialTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new DifferentialTransactionComment())->setContent($message));
     }
     $editor = id(new DifferentialTransactionEditor())->setActor($viewer)->setContentSourceFromConduitRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
     $editor->applyTransactions($revision, $xactions);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:61,代码来源:DifferentialConduitAPIMethod.php


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