Differential D9194 Diff 21860 src/applications/phriction/conduit/ConduitAPI_phriction_history_Method.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/conduit/ConduitAPI_phriction_history_Method.php
<?php | <?php | ||||
/** | |||||
* @group conduit | |||||
*/ | |||||
final class ConduitAPI_phriction_history_Method | final class ConduitAPI_phriction_history_Method | ||||
extends ConduitAPI_phriction_Method { | extends ConduitAPI_phriction_Method { | ||||
public function getMethodDescription() { | public function getMethodDescription() { | ||||
return "Retrieve history about a Phriction docuemnt."; | return pht('Retrieve history 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 list'; | return 'nonempty list'; | ||||
} | } | ||||
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( | $doc = id(new PhrictionDocumentQuery()) | ||||
'slug = %s', | ->setViewer($request->getUser()) | ||||
PhabricatorSlug::normalize($slug)); | ->withSlugs(array(PhabricatorSlug::normalize($slug))) | ||||
->executeOne(); | |||||
if (!$doc) { | if (!$doc) { | ||||
throw new ConduitException('ERR-BAD-DOCUMENT'); | throw new ConduitException('ERR-BAD-DOCUMENT'); | ||||
} | } | ||||
$content = id(new PhrictionContent())->loadAllWhere( | $content = id(new PhrictionContent())->loadAllWhere( | ||||
'documentID = %d ORDER BY version DESC', | 'documentID = %d ORDER BY version DESC', | ||||
$doc->getID()); | $doc->getID()); | ||||
Show All 11 Lines |