Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/xaction/DifferentialRevisionInlineTransaction.php
12256 views
1
<?php
2
3
final class DifferentialRevisionInlineTransaction
4
extends PhabricatorModularTransactionType {
5
6
// NOTE: This class is NOT an actual Differential modular transaction type!
7
// It does not extend "DifferentialRevisionTransactionType". Some day it
8
// should, but for now it's just reducing the amount of hackiness around
9
// supporting inline comments in the "transaction.search" Conduit API method.
10
11
const TRANSACTIONTYPE = 'internal.pretend-inline';
12
13
public function getTransactionTypeForConduit($xaction) {
14
return 'inline';
15
}
16
17
public function loadTransactionTypeConduitData(array $xactions) {
18
$viewer = $this->getViewer();
19
20
$changeset_ids = array();
21
foreach ($xactions as $xaction) {
22
$changeset_ids[] = $xaction->getComment()->getChangesetID();
23
}
24
25
$changesets = id(new DifferentialChangesetQuery())
26
->setViewer($viewer)
27
->withIDs($changeset_ids)
28
->execute();
29
30
$changesets = mpull($changesets, null, 'getID');
31
32
return $changesets;
33
}
34
35
public function getFieldValuesForConduit($object, $data) {
36
$comment = $object->getComment();
37
38
$changeset = $data[$comment->getChangesetID()];
39
$diff = $changeset->getDiff();
40
41
$is_done = false;
42
switch ($comment->getFixedState()) {
43
case PhabricatorInlineComment::STATE_DONE:
44
case PhabricatorInlineComment::STATE_UNDRAFT:
45
$is_done = true;
46
break;
47
}
48
49
return array(
50
'diff' => array(
51
'id' => (int)$diff->getID(),
52
'phid' => $diff->getPHID(),
53
),
54
'path' => $changeset->getDisplayFilename(),
55
'line' => (int)$comment->getLineNumber(),
56
'length' => (int)($comment->getLineLength() + 1),
57
'replyToCommentPHID' => $comment->getReplyToCommentPHID(),
58
'isDone' => $is_done,
59
);
60
}
61
62
}
63
64