Changeset View
Changeset View
Standalone View
Standalone View
src/applications/slowvote/conduit/SlowvoteInfoConduitAPIMethod.php
Show All 21 Lines | final class SlowvoteInfoConduitAPIMethod extends SlowvoteConduitAPIMethod { | ||||
protected function defineErrorTypes() { | protected function defineErrorTypes() { | ||||
return array( | return array( | ||||
'ERR_BAD_POLL' => pht('No such poll exists.'), | 'ERR_BAD_POLL' => pht('No such poll exists.'), | ||||
); | ); | ||||
} | } | ||||
protected function execute(ConduitAPIRequest $request) { | protected function execute(ConduitAPIRequest $request) { | ||||
$viewer = $this->getViewer(); | |||||
$poll_id = $request->getValue('poll_id'); | $poll_id = $request->getValue('poll_id'); | ||||
$poll = id(new PhabricatorSlowvotePoll())->load($poll_id); | |||||
$poll = id(new PhabricatorSlowvoteQuery()) | |||||
->setViewer($viewer) | |||||
->withIDs(array($poll_id)) | |||||
->executeOne(); | |||||
if (!$poll) { | if (!$poll) { | ||||
throw new ConduitException('ERR_BAD_POLL'); | throw new ConduitException('ERR_BAD_POLL'); | ||||
} | } | ||||
$result = array( | $result = array( | ||||
'id' => $poll->getID(), | 'id' => $poll->getID(), | ||||
'phid' => $poll->getPHID(), | 'phid' => $poll->getPHID(), | ||||
'authorPHID' => $poll->getAuthorPHID(), | 'authorPHID' => $poll->getAuthorPHID(), | ||||
'question' => $poll->getQuestion(), | 'question' => $poll->getQuestion(), | ||||
'uri' => PhabricatorEnv::getProductionURI('/V'.$poll->getID()), | 'uri' => PhabricatorEnv::getProductionURI('/V'.$poll->getID()), | ||||
); | ); | ||||
return $result; | return $result; | ||||
} | } | ||||
} | } |