Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / maniphest / conduit / ManiphestGetTaskTransactionsConduitAPIMethod.php
blob357d118bc4a2233159aea691b95791625b4c34ad
1 <?php
3 final class ManiphestGetTaskTransactionsConduitAPIMethod
4 extends ManiphestConduitAPIMethod {
6 public function getAPIMethodName() {
7 return 'maniphest.gettasktransactions';
10 public function getMethodDescription() {
11 return pht('Retrieve Maniphest task transactions.');
14 protected function defineParamTypes() {
15 return array(
16 'ids' => 'required list<int>',
20 protected function defineReturnType() {
21 return 'nonempty list<dict<string, wild>>';
24 public function getMethodStatus() {
25 return self::METHOD_STATUS_FROZEN;
28 public function getMethodStatusDescription() {
29 return pht(
30 'This method is frozen and will eventually be deprecated. New code '.
31 'should use "transaction.search" instead.');
34 protected function execute(ConduitAPIRequest $request) {
35 $results = array();
36 $task_ids = $request->getValue('ids');
38 if (!$task_ids) {
39 return $results;
42 $tasks = id(new ManiphestTaskQuery())
43 ->setViewer($request->getUser())
44 ->withIDs($task_ids)
45 ->execute();
46 $tasks = mpull($tasks, null, 'getPHID');
48 $transactions = array();
49 if ($tasks) {
50 $transactions = id(new ManiphestTransactionQuery())
51 ->setViewer($request->getUser())
52 ->withObjectPHIDs(mpull($tasks, 'getPHID'))
53 ->needComments(true)
54 ->execute();
57 foreach ($transactions as $transaction) {
58 $task_phid = $transaction->getObjectPHID();
59 if (empty($tasks[$task_phid])) {
60 continue;
63 $task_id = $tasks[$task_phid]->getID();
65 $comments = null;
66 if ($transaction->hasComment()) {
67 $comments = $transaction->getComment()->getContent();
70 $results[$task_id][] = array(
71 'taskID' => $task_id,
72 'transactionID' => $transaction->getID(),
73 'transactionPHID' => $transaction->getPHID(),
74 'transactionType' => $transaction->getTransactionType(),
75 'oldValue' => $transaction->getOldValue(),
76 'newValue' => $transaction->getNewValue(),
77 'comments' => $comments,
78 'authorPHID' => $transaction->getAuthorPHID(),
79 'dateCreated' => $transaction->getDateCreated(),
83 return $results;