[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/diffusion/conduit/ -> DiffusionGetLintMessagesConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class DiffusionGetLintMessagesConduitAPIMethod
   4    extends DiffusionConduitAPIMethod {
   5  
   6    public function getAPIMethodName() {
   7      return 'diffusion.getlintmessages';
   8    }
   9  
  10    public function getMethodStatus() {
  11      return self::METHOD_STATUS_UNSTABLE;
  12    }
  13  
  14    public function getMethodDescription() {
  15      return 'Get lint messages for existing code.';
  16    }
  17  
  18    public function defineParamTypes() {
  19      return array(
  20        'arcanistProject' => 'required string',
  21        'branch'          => 'optional string',
  22        'commit'          => 'optional string',
  23        'files'           => 'required list<string>',
  24      );
  25    }
  26  
  27    public function defineReturnType() {
  28      return 'list<dict>';
  29    }
  30  
  31    public function defineErrorTypes() {
  32      return array();
  33    }
  34  
  35    protected function execute(ConduitAPIRequest $request) {
  36      $project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere(
  37        'name = %s',
  38        $request->getValue('arcanistProject'));
  39      if (!$project || !$project->getRepositoryID()) {
  40        return array();
  41      }
  42  
  43      $branch_name = $request->getValue('branch');
  44      if ($branch_name == '') {
  45        $repository = id(new PhabricatorRepositoryQuery())
  46          ->setViewer($request->getUser())
  47          ->withIDs(array($project->getRepositoryID()))
  48          ->executeOne();
  49        $branch_name = $repository->getDefaultArcanistBranch();
  50      }
  51  
  52      $branch = id(new PhabricatorRepositoryBranch())->loadOneWhere(
  53        'repositoryID = %d AND name = %s',
  54        $project->getRepositoryID(),
  55        $branch_name);
  56      if (!$branch || !$branch->getLintCommit()) {
  57        return array();
  58      }
  59  
  60      $lint_messages = queryfx_all(
  61        $branch->establishConnection('r'),
  62        'SELECT path, line, code FROM %T WHERE branchID = %d AND path IN (%Ls)',
  63        PhabricatorRepository::TABLE_LINTMESSAGE,
  64        $branch->getID(),
  65        $request->getValue('files'));
  66  
  67      // TODO: Compare commit identifiers of individual files like in
  68      // DiffusionBrowseFileController::loadLintMessages().
  69  
  70      return $lint_messages;
  71    }
  72  
  73  }


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