[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/maniphest/conduit/ -> ManiphestUpdateConduitAPIMethod.php (source)

   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 'Update an existing Maniphest task.';
  11    }
  12  
  13    public function defineErrorTypes() {
  14      return array(
  15        'ERR-BAD-TASK'          => 'No such maniphest task exists.',
  16        'ERR-INVALID-PARAMETER' => 'Missing or malformed parameter.',
  17        'ERR-NO-EFFECT'         => 'Update has no effect.',
  18      );
  19    }
  20  
  21    public function defineParamTypes() {
  22      return $this->getTaskFields($is_new = false);
  23    }
  24  
  25    public function defineReturnType() {
  26      return 'nonempty dict';
  27    }
  28  
  29    protected function execute(ConduitAPIRequest $request) {
  30      $id = $request->getValue('id');
  31      $phid = $request->getValue('phid');
  32  
  33      if (($id && $phid) || (!$id && !$phid)) {
  34        throw new Exception("Specify exactly one of 'id' and 'phid'.");
  35      }
  36  
  37      if ($id) {
  38        $task = id(new ManiphestTaskQuery())
  39          ->setViewer($request->getUser())
  40          ->withIDs(array($id))
  41          ->executeOne();
  42      } else {
  43        $task = id(new ManiphestTaskQuery())
  44          ->setViewer($request->getUser())
  45          ->withPHIDs(array($phid))
  46          ->executeOne();
  47      }
  48  
  49      $params = $request->getAllParameters();
  50      unset($params['id']);
  51      unset($params['phid']);
  52  
  53      if (call_user_func_array('coalesce', $params) === null) {
  54        throw new ConduitException('ERR-NO-EFFECT');
  55      }
  56  
  57      if (!$task) {
  58        throw new ConduitException('ERR-BAD-TASK');
  59      }
  60  
  61      $this->applyRequest($task, $request, $is_new = false);
  62  
  63      return $this->buildTaskInfoDictionary($task);
  64    }
  65  
  66  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1