Path: blob/master/src/applications/maniphest/conduit/ManiphestQueryConduitAPIMethod.php
12256 views
<?php12final class ManiphestQueryConduitAPIMethod extends ManiphestConduitAPIMethod {34public function getAPIMethodName() {5return 'maniphest.query';6}78public function getMethodDescription() {9return pht('Execute complex searches for Maniphest tasks.');10}1112public function getMethodStatus() {13return self::METHOD_STATUS_FROZEN;14}1516public function getMethodStatusDescription() {17return pht(18'This method is frozen and will eventually be deprecated. New code '.19'should use "maniphest.search" instead.');20}2122protected function defineParamTypes() {23$statuses = array(24ManiphestTaskQuery::STATUS_ANY,25ManiphestTaskQuery::STATUS_OPEN,26ManiphestTaskQuery::STATUS_CLOSED,27ManiphestTaskQuery::STATUS_RESOLVED,28ManiphestTaskQuery::STATUS_WONTFIX,29ManiphestTaskQuery::STATUS_INVALID,30ManiphestTaskQuery::STATUS_SPITE,31ManiphestTaskQuery::STATUS_DUPLICATE,32);33$status_const = $this->formatStringConstants($statuses);3435$orders = array(36ManiphestTaskQuery::ORDER_PRIORITY,37ManiphestTaskQuery::ORDER_CREATED,38ManiphestTaskQuery::ORDER_MODIFIED,39);40$order_const = $this->formatStringConstants($orders);4142return array(43'ids' => 'optional list<uint>',44'phids' => 'optional list<phid>',45'ownerPHIDs' => 'optional list<phid>',46'authorPHIDs' => 'optional list<phid>',47'projectPHIDs' => 'optional list<phid>',48'ccPHIDs' => 'optional list<phid>',49'fullText' => 'optional string',5051'status' => 'optional '.$status_const,52'order' => 'optional '.$order_const,5354'limit' => 'optional int',55'offset' => 'optional int',56);57}5859protected function defineReturnType() {60return 'list';61}6263protected function execute(ConduitAPIRequest $request) {64$query = id(new ManiphestTaskQuery())65->setViewer($request->getUser())66->needProjectPHIDs(true)67->needSubscriberPHIDs(true);6869$task_ids = $request->getValue('ids');70if ($task_ids) {71$query->withIDs($task_ids);72}7374$task_phids = $request->getValue('phids');75if ($task_phids) {76$query->withPHIDs($task_phids);77}7879$owners = $request->getValue('ownerPHIDs');80if ($owners) {81$query->withOwners($owners);82}8384$authors = $request->getValue('authorPHIDs');85if ($authors) {86$query->withAuthors($authors);87}8889$projects = $request->getValue('projectPHIDs');90if ($projects) {91$query->withEdgeLogicPHIDs(92PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,93PhabricatorQueryConstraint::OPERATOR_AND,94$projects);95}9697$ccs = $request->getValue('ccPHIDs');98if ($ccs) {99$query->withSubscribers($ccs);100}101102$full_text = $request->getValue('fullText');103if ($full_text) {104throw new Exception(105pht(106'Parameter "fullText" is no longer supported. Use method '.107'"maniphest.search" with the "query" constraint instead.'));108}109110$status = $request->getValue('status');111if ($status) {112$query->withStatus($status);113}114115$order = $request->getValue('order');116if ($order) {117$query->setOrder($order);118}119120$limit = $request->getValue('limit');121if ($limit) {122$query->setLimit($limit);123}124125$offset = $request->getValue('offset');126if ($offset) {127$query->setOffset($offset);128}129130$results = $query->execute();131return $this->buildTaskInfoDictionaries($results);132}133134}135136137