3 final class PhabricatorPackagesPackageSearchEngine
4 extends PhabricatorApplicationSearchEngine
{
6 public function getResultTypeDescription() {
7 return pht('Packages');
10 public function getApplicationClassName() {
11 return 'PhabricatorPackagesApplication';
14 public function newQuery() {
15 return id(new PhabricatorPackagesPackageQuery());
18 public function canUseInPanelContext() {
22 protected function buildQueryFromParameters(array $map) {
23 $query = $this->newQuery();
25 if ($map['match'] !== null) {
26 $query->withNameNgrams($map['match']);
29 if ($map['publisherPHIDs']) {
30 $query->withPublisherPHIDs($map['publisherPHIDs']);
36 protected function buildCustomSearchFields() {
38 id(new PhabricatorSearchTextField())
39 ->setLabel(pht('Name Contains'))
41 ->setDescription(pht('Search for packages by name substring.')),
42 id(new PhabricatorSearchDatasourceField())
43 ->setLabel(pht('Publishers'))
44 ->setKey('publisherPHIDs')
45 ->setAliases(array('publisherPHID', 'publisher', 'publishers'))
46 ->setDatasource(new PhabricatorPackagesPublisherDatasource())
47 ->setDescription(pht('Search for packages by publisher.')),
51 protected function getURI($path) {
52 return '/packages/package/'.$path;
55 protected function getBuiltinQueryNames() {
57 'all' => pht('All Packages'),
63 public function buildSavedQueryFromBuiltin($query_key) {
64 $query = $this->newSavedQuery();
65 $query->setQueryKey($query_key);
72 return parent
::buildSavedQueryFromBuiltin($query_key);
75 protected function renderResultList(
77 PhabricatorSavedQuery
$query,
80 assert_instances_of($packages, 'PhabricatorPackagesPackage');
81 $viewer = $this->requireViewer();
83 $list = id(new PhabricatorPackagesPackageListView())
85 ->setPackages($packages)
88 return id(new PhabricatorApplicationSearchResultView())
89 ->setObjectList($list)
90 ->setNoDataString(pht('No packages found.'));