Path: blob/master/src/applications/maniphest/conduit/ManiphestUpdateConduitAPIMethod.php
12256 views
<?php12final class ManiphestUpdateConduitAPIMethod extends ManiphestConduitAPIMethod {34public function getAPIMethodName() {5return 'maniphest.update';6}78public function getMethodDescription() {9return pht('Update an existing Maniphest task.');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.edit" instead.');20}2122protected function defineErrorTypes() {23return array(24'ERR-BAD-TASK' => pht('No such Maniphest task exists.'),25'ERR-INVALID-PARAMETER' => pht('Missing or malformed parameter.'),26'ERR-NO-EFFECT' => pht('Update has no effect.'),27);28}2930protected function defineParamTypes() {31return $this->getTaskFields($is_new = false);32}3334protected function defineReturnType() {35return 'nonempty dict';36}3738protected function execute(ConduitAPIRequest $request) {39$id = $request->getValue('id');40$phid = $request->getValue('phid');4142if (($id && $phid) || (!$id && !$phid)) {43throw new Exception(44pht(45"Specify exactly one of '%s' and '%s'.",46'id',47'phid'));48}4950$query = id(new ManiphestTaskQuery())51->setViewer($request->getUser())52->needSubscriberPHIDs(true)53->needProjectPHIDs(true);54if ($id) {55$query->withIDs(array($id));56} else {57$query->withPHIDs(array($phid));58}59$task = $query->executeOne();6061$params = $request->getAllParameters();62unset($params['id']);63unset($params['phid']);6465if (call_user_func_array('coalesce', $params) === null) {66throw new ConduitException('ERR-NO-EFFECT');67}6869if (!$task) {70throw new ConduitException('ERR-BAD-TASK');71}7273$task = $this->applyRequest($task, $request, $is_new = false);7475return $this->buildTaskInfoDictionary($task);76}7778}798081