Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / packages / query / PhabricatorPackagesVersionSearchEngine.php
blobb3592ffd701b109b58e9e505d6465447ba7a3e34
1 <?php
3 final class PhabricatorPackagesVersionSearchEngine
4 extends PhabricatorApplicationSearchEngine {
6 public function getResultTypeDescription() {
7 return pht('Package Versions');
10 public function getApplicationClassName() {
11 return 'PhabricatorPackagesApplication';
14 public function newQuery() {
15 return id(new PhabricatorPackagesVersionQuery());
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['packagePHIDs']) {
30 $query->withPackagePHIDs($map['packagePHIDs']);
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 versions by name substring.')),
42 id(new PhabricatorSearchDatasourceField())
43 ->setLabel(pht('Packages'))
44 ->setKey('packagePHIDs')
45 ->setAliases(array('packagePHID', 'package', 'packages'))
46 ->setDatasource(new PhabricatorPackagesPackageDatasource())
47 ->setDescription(pht('Search for versions by package.')),
50 protected function getURI($path) {
51 return '/packages/version/'.$path;
54 protected function getBuiltinQueryNames() {
55 $names = array(
56 'all' => pht('All Versions'),
59 return $names;
62 public function buildSavedQueryFromBuiltin($query_key) {
63 $query = $this->newSavedQuery();
64 $query->setQueryKey($query_key);
66 switch ($query_key) {
67 case 'all':
68 return $query;
71 return parent::buildSavedQueryFromBuiltin($query_key);
74 protected function renderResultList(
75 array $versions,
76 PhabricatorSavedQuery $query,
77 array $handles) {
79 assert_instances_of($versions, 'PhabricatorPackagesVersion');
80 $viewer = $this->requireViewer();
82 $list = id(new PhabricatorPackagesVersionListView())
83 ->setViewer($viewer)
84 ->setVersions($versions)
85 ->newListView();
87 return id(new PhabricatorApplicationSearchResultView())
88 ->setObjectList($list)
89 ->setNoDataString(pht('No versions found.'));