[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/releeph/conduit/ -> ReleephGetBranchesConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class ReleephGetBranchesConduitAPIMethod extends ReleephConduitAPIMethod {
   4  
   5    public function getAPIMethodName() {
   6      return 'releeph.getbranches';
   7    }
   8  
   9    public function getMethodDescription() {
  10      return 'Return information about all active Releeph branches.';
  11    }
  12  
  13    public function defineParamTypes() {
  14      return array(
  15      );
  16    }
  17  
  18    public function defineReturnType() {
  19      return 'nonempty list<dict<string, wild>>';
  20    }
  21  
  22    public function defineErrorTypes() {
  23      return array(
  24      );
  25    }
  26  
  27    protected function execute(ConduitAPIRequest $request) {
  28      $results = array();
  29  
  30      $projects = id(new ReleephProductQuery())
  31        ->setViewer($request->getUser())
  32        ->withActive(1)
  33        ->execute();
  34  
  35      foreach ($projects as $project) {
  36        $repository = $project->getRepository();
  37  
  38        $branches = $project->loadRelatives(
  39          id(new ReleephBranch()),
  40          'releephProjectID',
  41          'getID',
  42          'isActive = 1');
  43  
  44        foreach ($branches as $branch) {
  45          $full_branch_name = $branch->getName();
  46  
  47          $cut_point_commit = $branch->loadOneRelative(
  48            id(new PhabricatorRepositoryCommit()),
  49            'phid',
  50            'getCutPointCommitPHID');
  51  
  52          $results[] = array(
  53            'project'         => $project->getName(),
  54            'repository'      => $repository->getCallsign(),
  55            'branch'          => $branch->getBasename(),
  56            'fullBranchName'  => $full_branch_name,
  57            'symbolicName'    => $branch->getSymbolicName(),
  58            'cutPoint'        => $cut_point_commit->getCommitIdentifier(),
  59          );
  60        }
  61      }
  62  
  63      return $results;
  64    }
  65  
  66  }


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