Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/maniphest/conduit/ManiphestUpdateConduitAPIMethod.php
12256 views
1
<?php
2
3
final class ManiphestUpdateConduitAPIMethod extends ManiphestConduitAPIMethod {
4
5
public function getAPIMethodName() {
6
return 'maniphest.update';
7
}
8
9
public function getMethodDescription() {
10
return pht('Update an existing Maniphest task.');
11
}
12
13
public function getMethodStatus() {
14
return self::METHOD_STATUS_FROZEN;
15
}
16
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.');
21
}
22
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.'),
28
);
29
}
30
31
protected function defineParamTypes() {
32
return $this->getTaskFields($is_new = false);
33
}
34
35
protected function defineReturnType() {
36
return 'nonempty dict';
37
}
38
39
protected function execute(ConduitAPIRequest $request) {
40
$id = $request->getValue('id');
41
$phid = $request->getValue('phid');
42
43
if (($id && $phid) || (!$id && !$phid)) {
44
throw new Exception(
45
pht(
46
"Specify exactly one of '%s' and '%s'.",
47
'id',
48
'phid'));
49
}
50
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));
59
}
60
$task = $query->executeOne();
61
62
$params = $request->getAllParameters();
63
unset($params['id']);
64
unset($params['phid']);
65
66
if (call_user_func_array('coalesce', $params) === null) {
67
throw new ConduitException('ERR-NO-EFFECT');
68
}
69
70
if (!$task) {
71
throw new ConduitException('ERR-BAD-TASK');
72
}
73
74
$task = $this->applyRequest($task, $request, $is_new = false);
75
76
return $this->buildTaskInfoDictionary($task);
77
}
78
79
}
80
81