3 final class PhabricatorConduitSearchEngine
4 extends PhabricatorApplicationSearchEngine
{
6 public function getResultTypeDescription() {
7 return pht('Conduit Methods');
10 public function getApplicationClassName() {
11 return 'PhabricatorConduitApplication';
14 public function canUseInPanelContext() {
18 public function getPageSize(PhabricatorSavedQuery
$saved) {
19 return PHP_INT_MAX
- 1;
22 public function buildSavedQueryFromRequest(AphrontRequest
$request) {
23 $saved = new PhabricatorSavedQuery();
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'));
33 public function buildQueryFromSavedQuery(PhabricatorSavedQuery
$saved) {
34 $query = id(new PhabricatorConduitMethodQuery());
36 $query->withIsStable($saved->getParameter('isStable'));
37 $query->withIsUnstable($saved->getParameter('isUnstable'));
38 $query->withIsDeprecated($saved->getParameter('isDeprecated'));
39 $query->withIsInternal(false);
41 $contains = $saved->getParameter('nameContains');
42 if (strlen($contains)) {
43 $query->withNameContains($contains);
49 public function buildSearchForm(
50 AphrontFormView
$form,
51 PhabricatorSavedQuery
$saved) {
55 id(new AphrontFormTextControl())
56 ->setLabel(pht('Name Contains'))
57 ->setName('nameContains')
58 ->setValue($saved->getParameter('nameContains')));
60 $is_stable = $saved->getParameter('isStable');
61 $is_unstable = $saved->getParameter('isUnstable');
62 $is_deprecated = $saved->getParameter('isDeprecated');
65 id(new AphrontFormCheckboxControl())
66 ->setLabel('Stability')
71 '<strong>%s</strong>: %s',
72 pht('Stable Methods'),
73 pht('Show established API methods with stable interfaces.')),
79 '<strong>%s</strong>: %s',
80 pht('Unstable Methods'),
81 pht('Show new methods which are subject to change.')),
87 '<strong>%s</strong>: %s',
88 pht('Deprecated Methods'),
90 'Show old methods which will be deleted in a future '.
91 'version of this software.')),
95 protected function getURI($path) {
96 return '/conduit/'.$path;
99 protected function getBuiltinQueryNames() {
101 'modern' => pht('Modern Methods'),
102 'all' => pht('All Methods'),
106 public function buildSavedQueryFromBuiltin($query_key) {
107 $query = $this->newSavedQuery();
108 $query->setQueryKey($query_key);
110 switch ($query_key) {
113 ->setParameter('isStable', true)
114 ->setParameter('isUnstable', true);
117 ->setParameter('isStable', true)
118 ->setParameter('isUnstable', true)
119 ->setParameter('isDeprecated', true);
122 return parent
::buildSavedQueryFromBuiltin($query_key);
125 protected function renderResultList(
127 PhabricatorSavedQuery
$query,
129 assert_instances_of($methods, 'ConduitAPIMethod');
131 $viewer = $this->requireViewer();
137 foreach ($methods as $method) {
138 $app = $method->getApplicationName();
139 if ($app !== $last) {
144 $list = id(new PHUIObjectItemListView());
145 $list->setHeader($app);
147 $app_object = $method->getApplication();
149 $app_name = $app_object->getName();
155 $method_name = $method->getAPIMethodName();
157 $item = id(new PHUIObjectItemView())
158 ->setHeader($method_name)
159 ->setHref($this->getApplicationURI('method/'.$method_name.'/'))
160 ->addAttribute($method->getMethodSummary());
162 switch ($method->getMethodStatus()) {
163 case ConduitAPIMethod
::METHOD_STATUS_STABLE
:
165 case ConduitAPIMethod
::METHOD_STATUS_UNSTABLE
:
166 $item->addIcon('fa-warning', pht('Unstable'));
167 $item->setStatusIcon('fa-warning yellow');
169 case ConduitAPIMethod
::METHOD_STATUS_DEPRECATED
:
170 $item->addIcon('fa-warning', pht('Deprecated'));
171 $item->setStatusIcon('fa-warning red');
173 case ConduitAPIMethod
::METHOD_STATUS_FROZEN
:
174 $item->addIcon('fa-archive', pht('Frozen'));
175 $item->setStatusIcon('fa-archive grey');
179 $list->addItem($item);
186 $result = new PhabricatorApplicationSearchResultView();
187 $result->setContent($out);