Differential D9194 Diff 21860 src/applications/phriction/conduit/ConduitAPI_phriction_edit_Method.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/conduit/ConduitAPI_phriction_edit_Method.php
<?php | <?php | ||||
/** | |||||
* @group conduit | |||||
*/ | |||||
final class ConduitAPI_phriction_edit_Method | final class ConduitAPI_phriction_edit_Method | ||||
extends ConduitAPI_phriction_Method { | extends ConduitAPI_phriction_Method { | ||||
public function getMethodDescription() { | public function getMethodDescription() { | ||||
return "Update a Phriction document."; | return "Update a Phriction document."; | ||||
} | } | ||||
public function defineParamTypes() { | public function defineParamTypes() { | ||||
Show All 12 Lines | final class ConduitAPI_phriction_edit_Method | ||||
public function defineErrorTypes() { | public function defineErrorTypes() { | ||||
return array( | return array( | ||||
); | ); | ||||
} | } | ||||
protected function execute(ConduitAPIRequest $request) { | protected function execute(ConduitAPIRequest $request) { | ||||
$slug = $request->getValue('slug'); | $slug = $request->getValue('slug'); | ||||
$doc = id(new PhrictionDocumentQuery()) | |||||
->setViewer($request->getUser()) | |||||
->withSlugs(array(PhabricatorSlug::normalize($slug))) | |||||
->requireCapabilities( | |||||
array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
PhabricatorPolicyCapability::CAN_EDIT, | |||||
)) | |||||
->executeOne(); | |||||
if (!$doc) { | |||||
throw new Exception(pht('No such document.')); | |||||
} | |||||
$editor = id(PhrictionDocumentEditor::newForSlug($slug)) | $editor = id(PhrictionDocumentEditor::newForSlug($slug)) | ||||
->setActor($request->getUser()) | ->setActor($request->getUser()) | ||||
->setTitle($request->getValue('title')) | ->setTitle($request->getValue('title')) | ||||
->setContent($request->getValue('content')) | ->setContent($request->getValue('content')) | ||||
->setDescription($request->getvalue('description')) | ->setDescription($request->getvalue('description')) | ||||
->save(); | ->save(); | ||||
return $this->buildDocumentInfoDictionary($editor->getDocument()); | return $this->buildDocumentInfoDictionary($editor->getDocument()); | ||||
} | } | ||||
} | } |