Differential D9194 Diff 21860 src/applications/phriction/conduit/ConduitAPI_phriction_info_Method.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/conduit/ConduitAPI_phriction_info_Method.php
<?php | <?php | ||||
/** | |||||
* @group conduit | |||||
*/ | |||||
final class ConduitAPI_phriction_info_Method | final class ConduitAPI_phriction_info_Method | ||||
extends ConduitAPI_phriction_Method { | extends ConduitAPI_phriction_Method { | ||||
public function getMethodDescription() { | public function getMethodDescription() { | ||||
return "Retrieve information about a Phriction document."; | return pht('Retrieve information about a Phriction document.'); | ||||
} | } | ||||
public function defineParamTypes() { | public function defineParamTypes() { | ||||
return array( | return array( | ||||
'slug' => 'required string', | 'slug' => 'required string', | ||||
); | ); | ||||
} | } | ||||
public function defineReturnType() { | public function defineReturnType() { | ||||
return 'nonempty dict'; | return 'nonempty dict'; | ||||
} | } | ||||
public function defineErrorTypes() { | public function defineErrorTypes() { | ||||
return array( | return array( | ||||
'ERR-BAD-DOCUMENT' => 'No such document exists.', | 'ERR-BAD-DOCUMENT' => 'No such document exists.', | ||||
); | ); | ||||
} | } | ||||
protected function execute(ConduitAPIRequest $request) { | protected function execute(ConduitAPIRequest $request) { | ||||
$slug = $request->getValue('slug'); | $slug = $request->getValue('slug'); | ||||
$doc = id(new PhrictionDocument())->loadOneWhere( | $document = id(new PhrictionDocumentQuery()) | ||||
'slug = %s', | ->setViewer($request->getUser()) | ||||
PhabricatorSlug::normalize($slug)); | ->withSlugs(array(PhabricatorSlug::normalize($slug))) | ||||
->needContent(true) | |||||
if (!$doc) { | ->executeOne(); | ||||
if (!$document) { | |||||
throw new ConduitException('ERR-BAD-DOCUMENT'); | throw new ConduitException('ERR-BAD-DOCUMENT'); | ||||
} | } | ||||
$content = id(new PhrictionContent())->load($doc->getContentID()); | return $this->buildDocumentInfoDictionary( | ||||
$doc->attachContent($content); | $document, | ||||
$document->getContent()); | |||||
return $this->buildDocumentInfoDictionary($doc); | |||||
} | } | ||||
} | } |