Use delegation to generalize application search controllers

Summary:
Ref T2625. Lifts almost all of the search logic out of Paste controllers and into Search.

This uses controller delegation for generalization. We use this in a few places, but don't use it very much yet. I think it's pretty reasonable as-is, but I might be able to make even more stuff free.

There are some slightly rough edges around routes, still, but I want to hit Phame and Differential (which both have multiple application search engines) before trying to generalize that.

Test Plan: Executed, browsed and managed Paste searches.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D6073
This commit is contained in:
epriestley
2013-05-30 14:09:02 -07:00
parent cf5009d5fb
commit 5d94a8a338
10 changed files with 367 additions and 237 deletions

View File

@@ -12,27 +12,9 @@ abstract class PhabricatorPasteController extends PhabricatorController {
$nav->addFilter('create', pht('Create Paste'));
}
$nav->addLabel(pht('Queries'));
$engine = id(new PhabricatorPasteSearchEngine())
->setViewer($user);
$named_queries = id(new PhabricatorNamedQueryQuery())
id(new PhabricatorPasteSearchEngine())
->setViewer($user)
->withUserPHIDs(array($user->getPHID()))
->withEngineClassNames(array(get_class($engine)))
->execute();
$named_queries = $named_queries + $engine->getBuiltinQueries($user);
foreach ($named_queries as $query) {
$nav->addFilter('query/'.$query->getQueryKey(), $query->getQueryName());
}
$nav->addFilter('savedqueries', pht('Edit Queries...'));
$nav->addLabel(pht('Search'));
$nav->addFilter('query/advanced', pht('Advanced Search'));
->addNavigationItems($nav);
$nav->selectFilter(null);