[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/slowvote/conduit/ -> SlowvoteInfoConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class SlowvoteInfoConduitAPIMethod extends SlowvoteConduitAPIMethod {
   4  
   5    public function getAPIMethodName() {
   6      return 'slowvote.info';
   7    }
   8  
   9    public function getMethodDescription() {
  10      return 'Retrieve an array of information about a poll.';
  11    }
  12  
  13    public function defineParamTypes() {
  14      return array(
  15        'poll_id' => 'required id',
  16      );
  17    }
  18  
  19    public function defineReturnType() {
  20      return 'nonempty dict';
  21    }
  22  
  23    public function defineErrorTypes() {
  24      return array(
  25        'ERR_BAD_POLL' => 'No such poll exists',
  26      );
  27    }
  28  
  29    protected function execute(ConduitAPIRequest $request) {
  30      $poll_id = $request->getValue('poll_id');
  31      $poll = id(new PhabricatorSlowvotePoll())->load($poll_id);
  32      if (!$poll) {
  33        throw new ConduitException('ERR_BAD_POLL');
  34      }
  35  
  36      $result = array(
  37        'id'          => $poll->getID(),
  38        'phid'        => $poll->getPHID(),
  39        'authorPHID'  => $poll->getAuthorPHID(),
  40        'question'    => $poll->getQuestion(),
  41        'uri'         => PhabricatorEnv::getProductionURI('/V'.$poll->getID()),
  42      );
  43  
  44      return $result;
  45    }
  46  
  47  }


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