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() {
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']);
36 protected function buildCustomSearchFields() {
38 id(new PhabricatorSearchTextField())
39 ->setLabel(pht('Name Contains'))
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() {
56 'all' => pht('All Versions'),
62 public function buildSavedQueryFromBuiltin($query_key) {
63 $query = $this->newSavedQuery();
64 $query->setQueryKey($query_key);
71 return parent
::buildSavedQueryFromBuiltin($query_key);
74 protected function renderResultList(
76 PhabricatorSavedQuery
$query,
79 assert_instances_of($versions, 'PhabricatorPackagesVersion');
80 $viewer = $this->requireViewer();
82 $list = id(new PhabricatorPackagesVersionListView())
84 ->setVersions($versions)
87 return id(new PhabricatorApplicationSearchResultView())
88 ->setObjectList($list)
89 ->setNoDataString(pht('No versions found.'));