Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/conduit/PhrictionInfoConduitAPIMethod.php
Show All 32 Lines | final class PhrictionInfoConduitAPIMethod extends PhrictionConduitAPIMethod { | ||||
protected function defineErrorTypes() { | protected function defineErrorTypes() { | ||||
return array( | return array( | ||||
'ERR-BAD-DOCUMENT' => pht('No such document exists.'), | 'ERR-BAD-DOCUMENT' => pht('No such document exists.'), | ||||
); | ); | ||||
} | } | ||||
protected function execute(ConduitAPIRequest $request) { | protected function execute(ConduitAPIRequest $request) { | ||||
$slug = $request->getValue('slug'); | $slug = $request->getValue('slug'); | ||||
if ($slug === null || !strlen($slug)) { | |||||
throw new Exception(pht('Field "slug" must be non-empty.')); | |||||
} | |||||
$document = id(new PhrictionDocumentQuery()) | $document = id(new PhrictionDocumentQuery()) | ||||
->setViewer($request->getUser()) | ->setViewer($request->getUser()) | ||||
->withSlugs(array(PhabricatorSlug::normalize($slug))) | ->withSlugs(array(PhabricatorSlug::normalize($slug))) | ||||
->needContent(true) | ->needContent(true) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$document) { | if (!$document) { | ||||
throw new ConduitException('ERR-BAD-DOCUMENT'); | throw new ConduitException('ERR-BAD-DOCUMENT'); | ||||
} | } | ||||
return $this->buildDocumentInfoDictionary($document); | return $this->buildDocumentInfoDictionary($document); | ||||
} | } | ||||
} | } |