1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 13:30:55 +01:00
phorge-phorge/src/applications/maniphest/conduit/ManiphestGetTaskTransactionsConduitAPIMethod.php
epriestley e5777cc849 Expose transaction PHID in maniphest.gettasktransactions
Summary: Fixes T6629.

Test Plan: {F238271}

Reviewers: btrahan, chad, 20after4

Reviewed By: 20after4

Subscribers: 20after4, epriestley

Maniphest Tasks: T6629

Differential Revision: https://secure.phabricator.com/D10898
2014-11-24 14:59:52 -08:00

80 lines
1.9 KiB
PHP

<?php
final class ManiphestGetTaskTransactionsConduitAPIMethod
extends ManiphestConduitAPIMethod {
public function getAPIMethodName() {
return 'maniphest.gettasktransactions';
}
public function getMethodDescription() {
return 'Retrieve Maniphest Task Transactions.';
}
public function defineParamTypes() {
return array(
'ids' => 'required list<int>',
);
}
public function defineReturnType() {
return 'nonempty list<dict<string, wild>>';
}
public function defineErrorTypes() {
return array(
);
}
protected function execute(ConduitAPIRequest $request) {
$results = array();
$task_ids = $request->getValue('ids');
if (!$task_ids) {
return $results;
}
$tasks = id(new ManiphestTaskQuery())
->setViewer($request->getUser())
->withIDs($task_ids)
->execute();
$tasks = mpull($tasks, null, 'getPHID');
$transactions = array();
if ($tasks) {
$transactions = id(new ManiphestTransactionQuery())
->setViewer($request->getUser())
->withObjectPHIDs(mpull($tasks, 'getPHID'))
->needComments(true)
->execute();
}
foreach ($transactions as $transaction) {
$task_phid = $transaction->getObjectPHID();
if (empty($tasks[$task_phid])) {
continue;
}
$task_id = $tasks[$task_phid]->getID();
$comments = null;
if ($transaction->hasComment()) {
$comments = $transaction->getComment()->getContent();
}
$results[$task_id][] = array(
'taskID' => $task_id,
'transactionPHID' => $transaction->getPHID(),
'transactionType' => $transaction->getTransactionType(),
'oldValue' => $transaction->getOldValue(),
'newValue' => $transaction->getNewValue(),
'comments' => $comments,
'authorPHID' => $transaction->getAuthorPHID(),
'dateCreated' => $transaction->getDateCreated(),
);
}
return $results;
}
}