[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  final class DifferentialGetRawDiffConduitAPIMethod
   4    extends DifferentialConduitAPIMethod {
   5  
   6    public function getAPIMethodName() {
   7      return 'differential.getrawdiff';
   8    }
   9  
  10    public function getMethodDescription() {
  11      return pht('Retrieve a raw diff');
  12    }
  13  
  14    public function defineParamTypes() {
  15      return array(
  16        'diffID' => 'required diffID',
  17      );
  18    }
  19  
  20    public function defineReturnType() {
  21      return 'nonempty string';
  22    }
  23  
  24    public function defineErrorTypes() {
  25      return array(
  26        'ERR_NOT_FOUND' => pht('Diff not found.'),
  27      );
  28    }
  29  
  30    protected function execute(ConduitAPIRequest $request) {
  31      $diff_id = $request->getValue('diffID');
  32  
  33      $viewer = $request->getUser();
  34  
  35      $diff = id(new DifferentialDiffQuery())
  36        ->withIDs(array($diff_id))
  37        ->setViewer($viewer)
  38        ->needChangesets(true)
  39        ->executeOne();
  40  
  41      if (!$diff) {
  42        throw new ConduitException('ERR_NOT_FOUND');
  43      }
  44  
  45      $renderer = id(new DifferentialRawDiffRenderer())
  46        ->setChangesets($diff->getChangesets())
  47        ->setViewer($viewer)
  48        ->setFormat('git');
  49  
  50      return $renderer->buildPatch();
  51    }
  52  
  53  }


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