Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / drydock / query / DrydockAuthorizationSearchEngine.php
blob16737a9dfe59811819613a78f3637e6f8f8d7c7d
1 <?php
3 final class DrydockAuthorizationSearchEngine
4 extends PhabricatorApplicationSearchEngine {
6 private $blueprint;
8 public function setBlueprint(DrydockBlueprint $blueprint) {
9 $this->blueprint = $blueprint;
10 return $this;
13 public function getBlueprint() {
14 return $this->blueprint;
17 public function getResultTypeDescription() {
18 return pht('Drydock Authorizations');
21 public function getApplicationClassName() {
22 return 'PhabricatorDrydockApplication';
25 public function canUseInPanelContext() {
26 return false;
29 public function newQuery() {
30 $query = new DrydockAuthorizationQuery();
32 $blueprint = $this->getBlueprint();
33 if ($blueprint) {
34 $query->withBlueprintPHIDs(array($blueprint->getPHID()));
37 return $query;
40 protected function buildQueryFromParameters(array $map) {
41 $query = $this->newQuery();
43 if ($map['blueprintPHIDs']) {
44 $query->withBlueprintPHIDs($map['blueprintPHIDs']);
47 if ($map['objectPHIDs']) {
48 $query->withObjectPHIDs($map['objectPHIDs']);
51 return $query;
54 protected function buildCustomSearchFields() {
55 return array(
56 id(new PhabricatorSearchDatasourceField())
57 ->setLabel(pht('Blueprints'))
58 ->setKey('blueprintPHIDs')
59 ->setConduitParameterType(new ConduitPHIDListParameterType())
60 ->setDescription(pht('Search authorizations for specific blueprints.'))
61 ->setAliases(array('blueprint', 'blueprints'))
62 ->setDatasource(new DrydockBlueprintDatasource()),
63 id(new PhabricatorPHIDsSearchField())
64 ->setLabel(pht('Objects'))
65 ->setKey('objectPHIDs')
66 ->setDescription(pht('Search authorizations from specific objects.'))
67 ->setAliases(array('object', 'objects')),
71 protected function getHiddenFields() {
72 return array(
73 'blueprintPHIDs',
74 'objectPHIDs',
78 protected function getURI($path) {
79 $blueprint = $this->getBlueprint();
80 if (!$blueprint) {
81 throw new PhutilInvalidStateException('setBlueprint');
83 $id = $blueprint->getID();
84 return "/drydock/blueprint/{$id}/authorizations/".$path;
87 protected function getBuiltinQueryNames() {
88 return array(
89 'all' => pht('All Authorizations'),
93 public function buildSavedQueryFromBuiltin($query_key) {
94 $query = $this->newSavedQuery();
95 $query->setQueryKey($query_key);
97 switch ($query_key) {
98 case 'all':
99 return $query;
102 return parent::buildSavedQueryFromBuiltin($query_key);
105 protected function renderResultList(
106 array $authorizations,
107 PhabricatorSavedQuery $query,
108 array $handles) {
110 $list = id(new DrydockAuthorizationListView())
111 ->setUser($this->requireViewer())
112 ->setAuthorizations($authorizations);
114 $result = new PhabricatorApplicationSearchResultView();
115 $result->setTable($list);
117 return $result;