Differential D20208 Diff 48249 src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php
| Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | $xaction_query = PhabricatorApplicationTransactionQuery::newQueryForObject( | ||||
| $object); | $object); | ||||
| $xaction_query | $xaction_query | ||||
| ->needHandles(false) | ->needHandles(false) | ||||
| ->withObjectPHIDs(array($object->getPHID())) | ->withObjectPHIDs(array($object->getPHID())) | ||||
| ->setViewer($viewer); | ->setViewer($viewer); | ||||
| $constraints = $request->getValue('constraints', array()); | $constraints = $request->getValue('constraints', array()); | ||||
| PhutilTypeSpec::checkMap( | |||||
| $constraints, | |||||
| array( | |||||
| 'phids' => 'optional list<string>', | |||||
| )); | |||||
| $with_phids = idx($constraints, 'phids'); | $xaction_query = $this->applyConstraints($constraints, $xaction_query); | ||||
| if ($with_phids === array()) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Constraint "phids" to "transaction.search" requires nonempty list, '. | |||||
| 'empty list provided.')); | |||||
| } | |||||
| if ($with_phids) { | |||||
| $xaction_query->withPHIDs($with_phids); | |||||
| } | |||||
| $xactions = $xaction_query->executeWithCursorPager($pager); | $xactions = $xaction_query->executeWithCursorPager($pager); | ||||
| $comment_map = array(); | $comment_map = array(); | ||||
| if ($xactions) { | if ($xactions) { | ||||
| $template = head($xactions)->getApplicationTransactionCommentObject(); | $template = head($xactions)->getApplicationTransactionCommentObject(); | ||||
| if ($template) { | if ($template) { | ||||
| ▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | protected function execute(ConduitAPIRequest $request) { | ||||
| } | } | ||||
| $results = array( | $results = array( | ||||
| 'data' => $data, | 'data' => $data, | ||||
| ); | ); | ||||
| return $this->addPagerResults($results, $pager); | return $this->addPagerResults($results, $pager); | ||||
| } | } | ||||
| private function applyConstraints( | |||||
| array $constraints, | |||||
| PhabricatorApplicationTransactionQuery $query) { | |||||
| PhutilTypeSpec::checkMap( | |||||
| $constraints, | |||||
| array( | |||||
| 'phids' => 'optional list<string>', | |||||
| 'authorPHIDs' => 'optional list<string>', | |||||
| )); | |||||
| $with_phids = idx($constraints, 'phids'); | |||||
| if ($with_phids === array()) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Constraint "phids" to "transaction.search" requires nonempty list, '. | |||||
| 'empty list provided.')); | |||||
| } | |||||
| if ($with_phids) { | |||||
| $query->withPHIDs($with_phids); | |||||
| } | |||||
| $with_authors = idx($constraints, 'authorPHIDs'); | |||||
| if ($with_authors === array()) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Constraint "authorPHIDs" to "transaction.search" requires '. | |||||
| 'nonempty list, empty list provided.')); | |||||
| } | |||||
| if ($with_authors) { | |||||
| $query->withAuthorPHIDs($with_authors); | |||||
| } | |||||
| return $query; | |||||
| } | |||||
| } | } | ||||