@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 162 lines 4.0 kB view raw
1<?php 2 3abstract class PhabricatorEditEngineAPIMethod 4 extends ConduitAPIMethod { 5 6 abstract public function newEditEngine(); 7 8 public function getApplication() { 9 $engine = $this->newEditEngine(); 10 $class = $engine->getEngineApplicationClass(); 11 return PhabricatorApplication::getByClass($class); 12 } 13 14 final protected function defineParamTypes() { 15 return array( 16 'transactions' => 'list<map<string, wild>>', 17 'objectIdentifier' => 'optional id|phid|string', 18 ); 19 } 20 21 final protected function defineReturnType() { 22 return 'map<string, wild>'; 23 } 24 25 final protected function execute(ConduitAPIRequest $request) { 26 $engine = $this->newEditEngine() 27 ->setViewer($request->getUser()); 28 29 return $engine->buildConduitResponse($request); 30 } 31 32 final public function getMethodDescription() { 33 return pht( 34 'This is a standard **ApplicationEditor** method which allows you to '. 35 'create and modify objects by applying transactions. For documentation '. 36 'on these endpoints, see '. 37 '**[[ %s | Conduit API: Using Edit Endpoints ]]**.', 38 PhabricatorEnv::getDoclink('Conduit API: Using Edit Endpoints')); 39 } 40 41 final protected function newDocumentationPages(PhabricatorUser $viewer) { 42 $engine = $this->newEditEngine() 43 ->setViewer($viewer); 44 45 $types = $engine->getConduitEditTypes(); 46 47 $out = array(); 48 49 return $this->buildEditTypesDocumentationPages($viewer, $engine, $types); 50 } 51 52 private function buildEditTypesDocumentationPages( 53 PhabricatorUser $viewer, 54 PhabricatorEditEngine $engine, 55 array $types) { 56 57 $pages = array(); 58 59 $summary_info = pht( 60 'This endpoint supports these types of transactions. See below for '. 61 'detailed information about each transaction type.'); 62 63 $rows = array(); 64 foreach ($types as $type) { 65 $rows[] = array( 66 $type->getEditType(), 67 $type->getConduitDescription(), 68 ); 69 } 70 71 $summary_table = id(new AphrontTableView($rows)) 72 ->setHeaders( 73 array( 74 pht('Key'), 75 pht('Description'), 76 )) 77 ->setColumnClasses( 78 array( 79 'prewrap', 80 'wide', 81 )); 82 83 $title = pht('Transaction Summary'); 84 $content = array( 85 $this->buildRemarkup($summary_info), 86 $summary_table, 87 ); 88 89 $pages[] = $this->newDocumentationBoxPage($viewer, $title, $content) 90 ->setAnchor('types'); 91 92 foreach ($types as $type) { 93 $section = array(); 94 95 $section[] = $type->getConduitDescription(); 96 97 $type_documentation = $type->getConduitDocumentation(); 98 if (phutil_nonempty_string($type_documentation)) { 99 $section[] = $type_documentation; 100 } 101 102 $section = implode("\n\n", $section); 103 104 $rows = array(); 105 106 $rows[] = array( 107 'type', 108 'const', 109 $type->getEditType(), 110 ); 111 112 $rows[] = array( 113 'value', 114 $type->getConduitType(), 115 $type->getConduitTypeDescription(), 116 ); 117 118 $type_table = id(new AphrontTableView($rows)) 119 ->setHeaders( 120 array( 121 pht('Key'), 122 pht('Type'), 123 pht('Description'), 124 )) 125 ->setColumnClasses( 126 array( 127 'prewrap', 128 'prewrap', 129 'wide', 130 )); 131 132 $title = $type->getEditType(); 133 $content = array( 134 $this->buildRemarkup($section), 135 $type_table, 136 ); 137 138 $pages[] = $this->newDocumentationBoxPage($viewer, $title, $content) 139 ->setAnchor($type->getEditType()) 140 ->setIconIcon('fa-pencil'); 141 } 142 143 return $pages; 144 } 145 146 147 private function buildRemarkup($remarkup) { 148 $viewer = $this->getViewer(); 149 150 $view = new PHUIRemarkupView($viewer, $remarkup); 151 152 $view->setRemarkupOptions( 153 array( 154 PHUIRemarkupView::OPTION_PRESERVE_LINEBREAKS => false, 155 )); 156 157 return id(new PHUIBoxView()) 158 ->appendChild($view) 159 ->addPadding(PHUI::PADDING_LARGE); 160 } 161 162}