@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 recaptime-dev/main 197 lines 5.6 kB view raw
1<?php 2 3final class PhabricatorConduitSearchEngine 4 extends PhabricatorApplicationSearchEngine { 5 6 public function getResultTypeDescription() { 7 return pht('Conduit Methods'); 8 } 9 10 public function getApplicationClassName() { 11 return PhabricatorConduitApplication::class; 12 } 13 14 public function canUseInPanelContext() { 15 return false; 16 } 17 18 public function getPageSize(PhabricatorSavedQuery $saved) { 19 return PHP_INT_MAX - 1; 20 } 21 22 public function buildSavedQueryFromRequest(AphrontRequest $request) { 23 $saved = new PhabricatorSavedQuery(); 24 25 $saved->setParameter('isStable', $request->getStr('isStable')); 26 $saved->setParameter('isUnstable', $request->getStr('isUnstable')); 27 $saved->setParameter('isDeprecated', $request->getStr('isDeprecated')); 28 $saved->setParameter('nameContains', $request->getStr('nameContains')); 29 30 return $saved; 31 } 32 33 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 34 $query = new PhabricatorConduitMethodQuery(); 35 36 $query->withIsStable($saved->getParameter('isStable')); 37 $query->withIsUnstable($saved->getParameter('isUnstable')); 38 $query->withIsDeprecated($saved->getParameter('isDeprecated')); 39 $query->withIsInternal(false); 40 41 $contains = $saved->getParameter('nameContains'); 42 if (phutil_nonempty_string($contains)) { 43 $query->withNameContains($contains); 44 } 45 46 return $query; 47 } 48 49 public function buildSearchForm( 50 AphrontFormView $form, 51 PhabricatorSavedQuery $saved) { 52 53 $form 54 ->appendChild( 55 id(new AphrontFormTextControl()) 56 ->setLabel(pht('Name Contains')) 57 ->setName('nameContains') 58 ->setValue($saved->getParameter('nameContains'))); 59 60 $is_stable = $saved->getParameter('isStable'); 61 $is_unstable = $saved->getParameter('isUnstable'); 62 $is_deprecated = $saved->getParameter('isDeprecated'); 63 $form 64 ->appendChild( 65 id(new AphrontFormCheckboxControl()) 66 ->setLabel('Stability') 67 ->addCheckbox( 68 'isStable', 69 1, 70 hsprintf( 71 '<strong>%s</strong>: %s', 72 pht('Stable Methods'), 73 pht('Show established API methods with stable interfaces.')), 74 $is_stable) 75 ->addCheckbox( 76 'isUnstable', 77 1, 78 hsprintf( 79 '<strong>%s</strong>: %s', 80 pht('Unstable Methods'), 81 pht('Show new methods which are subject to change.')), 82 $is_unstable) 83 ->addCheckbox( 84 'isDeprecated', 85 1, 86 hsprintf( 87 '<strong>%s</strong>: %s', 88 pht('Deprecated Methods'), 89 pht( 90 'Show old methods which will be deleted in a future '. 91 'version of this software.')), 92 $is_deprecated)); 93 } 94 95 protected function getURI($path) { 96 return '/conduit/'.$path; 97 } 98 99 protected function getBuiltinQueryNames() { 100 return array( 101 'modern' => pht('Modern Methods'), 102 'all' => pht('All Methods'), 103 ); 104 } 105 106 public function buildSavedQueryFromBuiltin($query_key) { 107 $query = $this->newSavedQuery(); 108 $query->setQueryKey($query_key); 109 110 switch ($query_key) { 111 case 'modern': 112 return $query 113 ->setParameter('isStable', true) 114 ->setParameter('isUnstable', true); 115 case 'all': 116 return $query 117 ->setParameter('isStable', true) 118 ->setParameter('isUnstable', true) 119 ->setParameter('isDeprecated', true); 120 } 121 122 return parent::buildSavedQueryFromBuiltin($query_key); 123 } 124 125 /** 126 * @param array<ConduitAPIMethod> $methods 127 * @param PhabricatorSavedQuery $query 128 * @param array<PhabricatorObjectHandle> $handles 129 */ 130 protected function renderResultList( 131 array $methods, 132 PhabricatorSavedQuery $query, 133 array $handles) { 134 assert_instances_of($methods, ConduitAPIMethod::class); 135 136 $viewer = $this->requireViewer(); 137 138 $out = array(); 139 140 $last = null; 141 $list = null; 142 foreach ($methods as $method) { 143 $app = $method->getApplicationName(); 144 if ($app !== $last) { 145 $last = $app; 146 if ($list) { 147 $out[] = $list; 148 } 149 $list = new PHUIObjectItemListView(); 150 $list->setHeader($app); 151 152 $app_object = $method->getApplication(); 153 if ($app_object) { 154 $app_name = $app_object->getName(); 155 } else { 156 $app_name = $app; 157 } 158 } 159 160 $method_name = $method->getAPIMethodName(); 161 162 $item = id(new PHUIObjectItemView()) 163 ->setHeader($method_name) 164 ->setHref($this->getApplicationURI('method/'.$method_name.'/')) 165 ->addAttribute($method->getMethodSummary()); 166 167 switch ($method->getMethodStatus()) { 168 case ConduitAPIMethod::METHOD_STATUS_STABLE: 169 break; 170 case ConduitAPIMethod::METHOD_STATUS_UNSTABLE: 171 $item->addIcon('fa-warning', pht('Unstable')); 172 $item->setStatusIcon('fa-warning yellow'); 173 break; 174 case ConduitAPIMethod::METHOD_STATUS_DEPRECATED: 175 $item->addIcon('fa-warning', pht('Deprecated')); 176 $item->setStatusIcon('fa-warning red'); 177 break; 178 case ConduitAPIMethod::METHOD_STATUS_FROZEN: 179 $item->addIcon('fa-archive', pht('Frozen')); 180 $item->setStatusIcon('fa-archive grey'); 181 break; 182 } 183 184 $list->addItem($item); 185 } 186 187 if ($list) { 188 $out[] = $list; 189 } 190 191 $result = new PhabricatorApplicationSearchResultView(); 192 $result->setContent($out); 193 194 return $result; 195 } 196 197}