Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / maniphest / conduit / ManiphestUpdateConduitAPIMethod.php
blobd8d02becd7c7a85dcc97478e436f7467353e9a62
1 <?php
3 final class ManiphestUpdateConduitAPIMethod extends ManiphestConduitAPIMethod {
5 public function getAPIMethodName() {
6 return 'maniphest.update';
9 public function getMethodDescription() {
10 return pht('Update an existing Maniphest task.');
13 public function getMethodStatus() {
14 return self::METHOD_STATUS_FROZEN;
17 public function getMethodStatusDescription() {
18 return pht(
19 'This method is frozen and will eventually be deprecated. New code '.
20 'should use "maniphest.edit" instead.');
23 protected function defineErrorTypes() {
24 return array(
25 'ERR-BAD-TASK' => pht('No such Maniphest task exists.'),
26 'ERR-INVALID-PARAMETER' => pht('Missing or malformed parameter.'),
27 'ERR-NO-EFFECT' => pht('Update has no effect.'),
31 protected function defineParamTypes() {
32 return $this->getTaskFields($is_new = false);
35 protected function defineReturnType() {
36 return 'nonempty dict';
39 protected function execute(ConduitAPIRequest $request) {
40 $id = $request->getValue('id');
41 $phid = $request->getValue('phid');
43 if (($id && $phid) || (!$id && !$phid)) {
44 throw new Exception(
45 pht(
46 "Specify exactly one of '%s' and '%s'.",
47 'id',
48 'phid'));
51 $query = id(new ManiphestTaskQuery())
52 ->setViewer($request->getUser())
53 ->needSubscriberPHIDs(true)
54 ->needProjectPHIDs(true);
55 if ($id) {
56 $query->withIDs(array($id));
57 } else {
58 $query->withPHIDs(array($phid));
60 $task = $query->executeOne();
62 $params = $request->getAllParameters();
63 unset($params['id']);
64 unset($params['phid']);
66 if (call_user_func_array('coalesce', $params) === null) {
67 throw new ConduitException('ERR-NO-EFFECT');
70 if (!$task) {
71 throw new ConduitException('ERR-BAD-TASK');
74 $task = $this->applyRequest($task, $request, $is_new = false);
76 return $this->buildTaskInfoDictionary($task);