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() {
20 id(new PhabricatorSearchTextField())
21 ->setLabel(pht('Name Contains'))
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']);
37 protected function getURI($path) {
38 return '/almanac/network/'.$path;
41 protected function getBuiltinQueryNames() {
43 'all' => pht('All Networks'),
49 public function buildSavedQueryFromBuiltin($query_key) {
51 $query = $this->newSavedQuery();
52 $query->setQueryKey($query_key);
59 return parent
::buildSavedQueryFromBuiltin($query_key);
62 protected function renderResultList(
64 PhabricatorSavedQuery
$query,
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.'));