@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at upstream/main 83 lines 2.4 kB view raw
1<?php 2 3final class PhrictionEditConduitAPIMethod extends PhrictionConduitAPIMethod { 4 5 public function getAPIMethodName() { 6 return 'phriction.edit'; 7 } 8 9 public function getMethodDescription() { 10 return pht('Update a Phriction document.'); 11 } 12 13 protected function defineParamTypes() { 14 return array( 15 'slug' => 'required string', 16 'title' => 'optional string', 17 'content' => 'optional string', 18 'description' => 'optional string', 19 ); 20 } 21 22 protected function defineReturnType() { 23 return 'nonempty dict'; 24 } 25 26 protected function defineErrorTypes() { 27 return array( 28 'ERR-BAD-DOCUMENT' => pht('No such document exists.'), 29 ); 30 } 31 32 protected function execute(ConduitAPIRequest $request) { 33 $slug = $request->getValue('slug'); 34 $document = null; 35 36 if ($slug !== null) { 37 $document = id(new PhrictionDocumentQuery()) 38 ->setViewer($request->getUser()) 39 ->withSlugs(array(PhabricatorSlug::normalize($slug))) 40 ->needContent(true) 41 ->requireCapabilities( 42 array( 43 PhabricatorPolicyCapability::CAN_VIEW, 44 PhabricatorPolicyCapability::CAN_EDIT, 45 )) 46 ->executeOne(); 47 } 48 if (!$document) { 49 throw new ConduitException('ERR-BAD-DOCUMENT'); 50 } 51 52 $xactions = array(); 53 if ($request->getValue('title')) { 54 $xactions[] = id(new PhrictionTransaction()) 55 ->setTransactionType( 56 PhrictionDocumentTitleTransaction::TRANSACTIONTYPE) 57 ->setNewValue($request->getValue('title')); 58 } 59 60 if ($request->getValue('content')) { 61 $xactions[] = id(new PhrictionTransaction()) 62 ->setTransactionType( 63 PhrictionDocumentContentTransaction::TRANSACTIONTYPE) 64 ->setNewValue($request->getValue('content')); 65 } 66 67 $editor = id(new PhrictionTransactionEditor()) 68 ->setActor($request->getUser()) 69 ->setContentSource($request->newContentSource()) 70 ->setContinueOnNoEffect(true) 71 ->setDescription((string)$request->getValue('description')); 72 73 try { 74 $editor->applyTransactions($document, $xactions); 75 } catch (PhabricatorApplicationTransactionValidationException $ex) { 76 // TODO - some magical hotness via T5873 77 throw $ex; 78 } 79 80 return $this->buildDocumentInfoDictionary($document); 81 } 82 83}