Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / packages / query / PhabricatorPackagesPackageSearchEngine.php
blob817321dec1f828e8e79357883a269d94b810b06a
1 <?php
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() {
19 return false;
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']);
33 return $query;
36 protected function buildCustomSearchFields() {
37 return array(
38 id(new PhabricatorSearchTextField())
39 ->setLabel(pht('Name Contains'))
40 ->setKey('match')
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() {
56 $names = array(
57 'all' => pht('All Packages'),
60 return $names;
63 public function buildSavedQueryFromBuiltin($query_key) {
64 $query = $this->newSavedQuery();
65 $query->setQueryKey($query_key);
67 switch ($query_key) {
68 case 'all':
69 return $query;
72 return parent::buildSavedQueryFromBuiltin($query_key);
75 protected function renderResultList(
76 array $packages,
77 PhabricatorSavedQuery $query,
78 array $handles) {
80 assert_instances_of($packages, 'PhabricatorPackagesPackage');
81 $viewer = $this->requireViewer();
83 $list = id(new PhabricatorPackagesPackageListView())
84 ->setViewer($viewer)
85 ->setPackages($packages)
86 ->newListView();
88 return id(new PhabricatorApplicationSearchResultView())
89 ->setObjectList($list)
90 ->setNoDataString(pht('No packages found.'));