[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/differential/conduit/ -> DifferentialCloseConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class DifferentialCloseConduitAPIMethod
   4    extends DifferentialConduitAPIMethod {
   5  
   6    public function getAPIMethodName() {
   7      return 'differential.close';
   8    }
   9  
  10    public function getMethodDescription() {
  11      return pht('Close a Differential revision.');
  12    }
  13  
  14    public function defineParamTypes() {
  15      return array(
  16        'revisionID' => 'required int',
  17      );
  18    }
  19  
  20    public function defineReturnType() {
  21      return 'void';
  22    }
  23  
  24    public function defineErrorTypes() {
  25      return array(
  26        'ERR_NOT_FOUND' => 'Revision was not found.',
  27      );
  28    }
  29  
  30    protected function execute(ConduitAPIRequest $request) {
  31      $viewer = $request->getUser();
  32      $id = $request->getValue('revisionID');
  33  
  34      $revision = id(new DifferentialRevisionQuery())
  35        ->withIDs(array($id))
  36        ->setViewer($viewer)
  37        ->needReviewerStatus(true)
  38        ->executeOne();
  39      if (!$revision) {
  40        throw new ConduitException('ERR_NOT_FOUND');
  41      }
  42  
  43      $xactions = array();
  44      $xactions[] = id(new DifferentialTransaction())
  45        ->setTransactionType(DifferentialTransaction::TYPE_ACTION)
  46        ->setNewValue(DifferentialAction::ACTION_CLOSE);
  47  
  48      $content_source = PhabricatorContentSource::newForSource(
  49        PhabricatorContentSource::SOURCE_CONDUIT,
  50        array());
  51  
  52      $editor = id(new DifferentialTransactionEditor())
  53        ->setActor($viewer)
  54        ->setContentSourceFromConduitRequest($request)
  55        ->setContinueOnMissingFields(true)
  56        ->setContinueOnNoEffect(true);
  57  
  58      $editor->applyTransactions($revision, $xactions);
  59  
  60      return;
  61    }
  62  
  63  }


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