[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  final class DifferentialGetRevisionCommentsConduitAPIMethod
   4    extends DifferentialConduitAPIMethod {
   5  
   6    public function getAPIMethodName() {
   7      return 'differential.getrevisioncomments';
   8    }
   9  
  10    public function getMethodStatus() {
  11      return self::METHOD_STATUS_DEPRECATED;
  12    }
  13  
  14    public function getMethodStatusDescription() {
  15      return pht('Obsolete and doomed, see T2222.');
  16    }
  17  
  18    public function getMethodDescription() {
  19      return 'Retrieve Differential Revision Comments.';
  20    }
  21  
  22    public function defineParamTypes() {
  23      return array(
  24        'ids' => 'required list<int>',
  25        'inlines' => 'optional bool (deprecated)',
  26      );
  27    }
  28  
  29    public function defineReturnType() {
  30      return 'nonempty list<dict<string, wild>>';
  31    }
  32  
  33    public function defineErrorTypes() {
  34      return array(
  35      );
  36    }
  37  
  38    protected function execute(ConduitAPIRequest $request) {
  39      $viewer = $request->getUser();
  40      $results = array();
  41      $revision_ids = $request->getValue('ids');
  42  
  43      if (!$revision_ids) {
  44        return $results;
  45      }
  46  
  47      $revisions = id(new DifferentialRevisionQuery())
  48        ->setViewer($viewer)
  49        ->withIDs($revision_ids)
  50        ->execute();
  51  
  52      if (!$revisions) {
  53        return $results;
  54      }
  55  
  56      $xactions = id(new DifferentialTransactionQuery())
  57        ->setViewer($viewer)
  58        ->withObjectPHIDs(mpull($revisions, 'getPHID'))
  59        ->execute();
  60  
  61      $revisions = mpull($revisions, null, 'getPHID');
  62  
  63      foreach ($xactions as $xaction) {
  64        $revision = idx($revisions, $xaction->getObjectPHID());
  65        if (!$revision) {
  66          continue;
  67        }
  68  
  69        $type = $xaction->getTransactionType();
  70        if ($type == DifferentialTransaction::TYPE_ACTION) {
  71          $action = $xaction->getNewValue();
  72        } else if ($type == PhabricatorTransactions::TYPE_COMMENT) {
  73          $action = 'comment';
  74        } else {
  75          $action = 'none';
  76        }
  77  
  78        $result = array(
  79          'revisionID'  => $revision->getID(),
  80          'action'      => $action,
  81          'authorPHID'  => $xaction->getAuthorPHID(),
  82          'dateCreated' => $xaction->getDateCreated(),
  83          'content'     => ($xaction->hasComment()
  84            ? $xaction->getComment()->getContent()
  85            : null),
  86        );
  87  
  88        $results[$revision->getID()][] = $result;
  89      }
  90  
  91      return $results;
  92    }
  93  
  94  }


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