[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/phriction/conduit/ -> PhrictionInfoConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class PhrictionInfoConduitAPIMethod extends PhrictionConduitAPIMethod {
   4  
   5    public function getAPIMethodName() {
   6      return 'phriction.info';
   7    }
   8  
   9    public function getMethodDescription() {
  10      return pht('Retrieve information about a Phriction document.');
  11    }
  12  
  13    public function defineParamTypes() {
  14      return array(
  15        'slug' => 'required string',
  16      );
  17    }
  18  
  19    public function defineReturnType() {
  20      return 'nonempty dict';
  21    }
  22  
  23    public function defineErrorTypes() {
  24      return array(
  25        'ERR-BAD-DOCUMENT' => 'No such document exists.',
  26      );
  27    }
  28  
  29    protected function execute(ConduitAPIRequest $request) {
  30      $slug = $request->getValue('slug');
  31  
  32      $document = id(new PhrictionDocumentQuery())
  33        ->setViewer($request->getUser())
  34        ->withSlugs(array(PhabricatorSlug::normalize($slug)))
  35        ->needContent(true)
  36        ->executeOne();
  37      if (!$document) {
  38        throw new ConduitException('ERR-BAD-DOCUMENT');
  39      }
  40  
  41      return $this->buildDocumentInfoDictionary(
  42        $document,
  43        $document->getContent());
  44    }
  45  
  46  }


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