Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/conduit/PhrictionEditConduitAPIMethod.php
- This file was copied to src/applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php.
<?php | <?php | ||||
final class PhrictionEditConduitAPIMethod extends PhrictionConduitAPIMethod { | final class PhrictionEditConduitAPIMethod extends PhrictionConduitAPIMethod { | ||||
public function getAPIMethodName() { | public function getAPIMethodName() { | ||||
return 'phriction.edit'; | return 'phriction.edit'; | ||||
} | } | ||||
public function getMethodDescription() { | public function getMethodDescription() { | ||||
return 'Update a Phriction document.'; | return pht('Update a Phriction document.'); | ||||
} | } | ||||
public function defineParamTypes() { | public function defineParamTypes() { | ||||
return array( | return array( | ||||
'slug' => 'required string', | 'slug' => 'required string', | ||||
'title' => 'optional string', | 'title' => 'optional string', | ||||
'content' => 'optional string', | 'content' => 'optional string', | ||||
'description' => 'optional string', | 'description' => 'optional string', | ||||
Show All 33 Lines | protected function execute(ConduitAPIRequest $request) { | ||||
$xactions[] = id(new PhrictionTransaction()) | $xactions[] = id(new PhrictionTransaction()) | ||||
->setTransactionType(PhrictionTransaction::TYPE_CONTENT) | ->setTransactionType(PhrictionTransaction::TYPE_CONTENT) | ||||
->setNewValue($request->getValue('content')); | ->setNewValue($request->getValue('content')); | ||||
$editor = id(new PhrictionTransactionEditor()) | $editor = id(new PhrictionTransactionEditor()) | ||||
->setActor($request->getUser()) | ->setActor($request->getUser()) | ||||
->setContentSourceFromConduitRequest($request) | ->setContentSourceFromConduitRequest($request) | ||||
->setContinueOnNoEffect(true) | ->setContinueOnNoEffect(true) | ||||
->setDescription($request->getValue('description')) | ->setDescription($request->getValue('description')); | ||||
->applyTransactions($doc, $xactions); | |||||
try { | |||||
$editor->applyTransactions($doc, $xactions); | |||||
} catch (PhabricatorApplicationTransactionValidationException $ex) { | |||||
// TODO - some magical hotness via T5873 | |||||
throw $ex; | |||||
} | |||||
return $this->buildDocumentInfoDictionary($doc); | return $this->buildDocumentInfoDictionary($doc); | ||||
} | } | ||||
} | } |