1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 11:22:40 +01:00
phorge-phorge/src/applications/nuance/query/NuanceSourceSearchEngine.php

79 lines
1.7 KiB
PHP
Raw Normal View History

<?php
final class NuanceSourceSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getApplicationClassName() {
return 'PhabricatorNuanceApplication';
}
public function getResultTypeDescription() {
return pht('Nuance Sources');
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
return $saved;
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new NuanceSourceQuery());
return $query;
}
public function buildSearchForm(
AphrontFormView $form,
PhabricatorSavedQuery $saved_query) {}
protected function getURI($path) {
return '/nuance/source/'.$path;
}
protected function getBuiltinQueryNames() {
$names = array(
'all' => pht('All Sources'),
);
return $names;
}
public function buildSavedQueryFromBuiltin($query_key) {
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
switch ($query_key) {
case 'all':
return $query;
}
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function renderResultList(
array $sources,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($sources, 'NuanceSource');
$viewer = $this->requireViewer();
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($sources as $source) {
$item = id(new PHUIObjectItemView())
->setObjectName(pht('Source %d', $source->getID()))
->setHeader($source->getName())
->setHref($source->getURI());
$item->addIcon('none', $source->getType());
$list->addItem($item);
}
return $list;
}
}