Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/query/AlmanacDeviceSearchEngine.php
<?php | <?php | ||||
final class AlmanacDeviceSearchEngine | final class AlmanacDeviceSearchEngine | ||||
extends PhabricatorApplicationSearchEngine { | extends PhabricatorApplicationSearchEngine { | ||||
public function getResultTypeDescription() { | public function getResultTypeDescription() { | ||||
return pht('Almanac Devices'); | return pht('Almanac Devices'); | ||||
} | } | ||||
public function getApplicationClassName() { | public function getApplicationClassName() { | ||||
return 'PhabricatorAlmanacApplication'; | return 'PhabricatorAlmanacApplication'; | ||||
} | } | ||||
public function buildSavedQueryFromRequest(AphrontRequest $request) { | public function newQuery() { | ||||
$saved = new PhabricatorSavedQuery(); | return new AlmanacDeviceQuery(); | ||||
} | |||||
return $saved; | protected function buildCustomSearchFields() { | ||||
return array( | |||||
id(new PhabricatorSearchTextField()) | |||||
->setLabel(pht('Name Contains')) | |||||
->setKey('match') | |||||
->setDescription(pht('Search for devices by name substring.')), | |||||
); | |||||
} | } | ||||
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { | protected function buildQueryFromParameters(array $map) { | ||||
$query = id(new AlmanacDeviceQuery()); | $query = $this->newQuery(); | ||||
return $query; | if ($map['match'] !== null) { | ||||
$query->withNameNgrams($map['match']); | |||||
} | } | ||||
public function buildSearchForm( | return $query; | ||||
AphrontFormView $form, | } | ||||
PhabricatorSavedQuery $saved_query) {} | |||||
protected function getURI($path) { | protected function getURI($path) { | ||||
return '/almanac/device/'.$path; | return '/almanac/device/'.$path; | ||||
} | } | ||||
protected function getBuiltinQueryNames() { | protected function getBuiltinQueryNames() { | ||||
$names = array( | $names = array( | ||||
'all' => pht('All Devices'), | 'all' => pht('All Devices'), | ||||
Show All 10 Lines | public function buildSavedQueryFromBuiltin($query_key) { | ||||
switch ($query_key) { | switch ($query_key) { | ||||
case 'all': | case 'all': | ||||
return $query; | return $query; | ||||
} | } | ||||
return parent::buildSavedQueryFromBuiltin($query_key); | return parent::buildSavedQueryFromBuiltin($query_key); | ||||
} | } | ||||
protected function getRequiredHandlePHIDsForResultList( | |||||
array $devices, | |||||
PhabricatorSavedQuery $query) { | |||||
return array(); | |||||
} | |||||
protected function renderResultList( | protected function renderResultList( | ||||
array $devices, | array $devices, | ||||
PhabricatorSavedQuery $query, | PhabricatorSavedQuery $query, | ||||
array $handles) { | array $handles) { | ||||
assert_instances_of($devices, 'AlmanacDevice'); | assert_instances_of($devices, 'AlmanacDevice'); | ||||
$viewer = $this->requireViewer(); | $viewer = $this->requireViewer(); | ||||
Show All 20 Lines |