Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / almanac / query / AlmanacNetworkSearchEngine.php
blob53f9b24e444358da366b20fe51e96cfb8f46bb82
1 <?php
3 final class AlmanacNetworkSearchEngine
4 extends PhabricatorApplicationSearchEngine {
6 public function getResultTypeDescription() {
7 return pht('Almanac Networks');
10 public function getApplicationClassName() {
11 return 'PhabricatorAlmanacApplication';
14 public function newQuery() {
15 return new AlmanacNetworkQuery();
18 protected function buildCustomSearchFields() {
19 return array(
20 id(new PhabricatorSearchTextField())
21 ->setLabel(pht('Name Contains'))
22 ->setKey('match')
23 ->setDescription(pht('Search for networks by name substring.')),
27 protected function buildQueryFromParameters(array $map) {
28 $query = $this->newQuery();
30 if ($map['match'] !== null) {
31 $query->withNameNgrams($map['match']);
34 return $query;
37 protected function getURI($path) {
38 return '/almanac/network/'.$path;
41 protected function getBuiltinQueryNames() {
42 $names = array(
43 'all' => pht('All Networks'),
46 return $names;
49 public function buildSavedQueryFromBuiltin($query_key) {
51 $query = $this->newSavedQuery();
52 $query->setQueryKey($query_key);
54 switch ($query_key) {
55 case 'all':
56 return $query;
59 return parent::buildSavedQueryFromBuiltin($query_key);
62 protected function renderResultList(
63 array $networks,
64 PhabricatorSavedQuery $query,
65 array $handles) {
66 assert_instances_of($networks, 'AlmanacNetwork');
68 $viewer = $this->requireViewer();
70 $list = new PHUIObjectItemListView();
71 $list->setUser($viewer);
72 foreach ($networks as $network) {
73 $id = $network->getID();
75 $item = id(new PHUIObjectItemView())
76 ->setObjectName(pht('Network %d', $id))
77 ->setHeader($network->getName())
78 ->setHref($this->getApplicationURI("network/{$id}/"))
79 ->setObject($network);
81 $list->addItem($item);
84 $result = new PhabricatorApplicationSearchResultView();
85 $result->setObjectList($list);
86 $result->setNoDataString(pht('No Almanac Networks found.'));
88 return $result;