[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/macro/conduit/ -> MacroQueryConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class MacroQueryConduitAPIMethod extends MacroConduitAPIMethod {
   4  
   5    public function getAPIMethodName() {
   6      return 'macro.query';
   7    }
   8  
   9    public function getMethodDescription() {
  10      return 'Retrieve image macro information.';
  11    }
  12  
  13    public function defineParamTypes() {
  14      return array(
  15        'authorPHIDs' => 'optional list<phid>',
  16        'phids'       => 'optional list<phid>',
  17        'ids'         => 'optional list<id>',
  18        'names'       => 'optional list<string>',
  19        'nameLike'    => 'optional string',
  20      );
  21    }
  22  
  23    public function defineReturnType() {
  24      return 'list<dict>';
  25    }
  26  
  27    public function defineErrorTypes() {
  28      return array(
  29      );
  30    }
  31  
  32    protected function execute(ConduitAPIRequest $request) {
  33      $query = id(new PhabricatorMacroQuery())
  34        ->setViewer($request->getUser())
  35        ->needFiles(true);
  36  
  37      $author_phids = $request->getValue('authorPHIDs');
  38      $phids = $request->getValue('phids');
  39      $ids = $request->getValue('ids');
  40      $name_like = $request->getValue('nameLike');
  41      $names = $request->getValue('names');
  42  
  43      if ($author_phids) {
  44        $query->withAuthorPHIDs($author_phids);
  45      }
  46  
  47      if ($phids) {
  48        $query->withPHIDs($phids);
  49      }
  50  
  51      if ($ids) {
  52        $query->withIDs($ids);
  53      }
  54  
  55      if ($name_like) {
  56        $query->withNameLike($name_like);
  57      }
  58  
  59      if ($names) {
  60        $query->withNames($names);
  61      }
  62  
  63      $macros = $query->execute();
  64  
  65      if (!$macros) {
  66        return array();
  67      }
  68  
  69      $results = array();
  70      foreach ($macros as $macro) {
  71        $file = $macro->getFile();
  72        $results[$macro->getName()] = array(
  73          'uri' => $file->getBestURI(),
  74          'phid' => $macro->getPHID(),
  75          'authorPHID' => $file->getAuthorPHID(),
  76          'dateCreated' => $file->getDateCreated(),
  77          'filePHID' => $file->getPHID(),
  78        );
  79      }
  80  
  81      return $results;
  82    }
  83  
  84  }


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