[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/arcanist/conduit/ -> ArcanistProjectInfoConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class ArcanistProjectInfoConduitAPIMethod
   4    extends ArcanistConduitAPIMethod {
   5  
   6    public function getAPIMethodName() {
   7      return 'arcanist.projectinfo';
   8    }
   9  
  10    public function getMethodDescription() {
  11      return 'Get information about Arcanist projects.';
  12    }
  13  
  14    public function defineParamTypes() {
  15      return array(
  16        'name' => 'required string',
  17      );
  18    }
  19  
  20    public function defineReturnType() {
  21      return 'nonempty dict';
  22    }
  23  
  24    public function defineErrorTypes() {
  25      return array(
  26        'ERR-BAD-ARCANIST-PROJECT' => 'No such project exists.',
  27      );
  28    }
  29  
  30    protected function execute(ConduitAPIRequest $request) {
  31      $name = $request->getValue('name');
  32  
  33      $project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere(
  34        'name = %s',
  35        $name);
  36  
  37      if (!$project) {
  38        throw new ConduitException('ERR-BAD-ARCANIST-PROJECT');
  39      }
  40  
  41      $repository = $project->loadRepository();
  42  
  43      $repository_phid = null;
  44      $tracked = false;
  45      $encoding = null;
  46      $dictionary = array();
  47      if ($repository) {
  48        $repository_phid = $repository->getPHID();
  49        $tracked = $repository->isTracked();
  50        $encoding = $repository->getDetail('encoding');
  51        $dictionary = $repository->toDictionary();
  52      }
  53  
  54      return array(
  55        'name'            => $project->getName(),
  56        'phid'            => $project->getPHID(),
  57        'repositoryPHID'  => $repository_phid,
  58        'tracked'         => $tracked,
  59        'encoding'        => $encoding,
  60        'repository'      => $dictionary,
  61      );
  62    }
  63  
  64  }


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