[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  final class DiffusionFindSymbolsConduitAPIMethod
   4    extends DiffusionConduitAPIMethod {
   5  
   6    public function getAPIMethodName() {
   7      return 'diffusion.findsymbols';
   8    }
   9  
  10    public function getMethodDescription() {
  11      return 'Retrieve Diffusion symbol information.';
  12    }
  13  
  14    public function defineParamTypes() {
  15      return array(
  16        'name'        => 'optional string',
  17        'namePrefix'  => 'optional string',
  18        'context'     => 'optional string',
  19        'language'    => 'optional string',
  20        'type'        => 'optional string',
  21      );
  22    }
  23  
  24    public function defineReturnType() {
  25      return 'nonempty list<dict>';
  26    }
  27  
  28    public function defineErrorTypes() {
  29      return array(
  30      );
  31    }
  32  
  33    protected function execute(ConduitAPIRequest $request) {
  34      $name = $request->getValue('name');
  35      $name_prefix = $request->getValue('namePrefix');
  36      $context = $request->getValue('context');
  37      $language = $request->getValue('language');
  38      $type = $request->getValue('type');
  39  
  40      $query = new DiffusionSymbolQuery();
  41      if ($name !== null) {
  42        $query->setName($name);
  43      }
  44      if ($name_prefix !== null) {
  45        $query->setNamePrefix($name_prefix);
  46      }
  47      if ($context !== null) {
  48        $query->setContext($context);
  49      }
  50      if ($language !== null) {
  51        $query->setLanguage($language);
  52      }
  53      if ($type !== null) {
  54        $query->setType($type);
  55      }
  56  
  57      $query->needPaths(true);
  58      $query->needArcanistProjects(true);
  59      $query->needRepositories(true);
  60  
  61      $results = $query->execute();
  62  
  63  
  64      $response = array();
  65      foreach ($results as $result) {
  66        $uri = $result->getURI();
  67        if ($uri) {
  68          $uri = PhabricatorEnv::getProductionURI($uri);
  69        }
  70  
  71        $response[] = array(
  72          'name'        => $result->getSymbolName(),
  73          'context'     => $result->getSymbolContext(),
  74          'type'        => $result->getSymbolType(),
  75          'language'    => $result->getSymbolLanguage(),
  76          'path'        => $result->getPath(),
  77          'line'        => $result->getLineNumber(),
  78          'uri'         => $uri,
  79        );
  80      }
  81  
  82      return $response;
  83    }
  84  
  85  }


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