1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 04:20:55 +01:00
phorge-phorge/src/applications/search/controller/PhabricatorSearchOrderController.php
Chad Little 09ab82faef Update Search for handleRequest
Summary: Ref T8628. Updates Search.

Test Plan: Did various searches, saved new queries, reordered, ran new queries.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D14268
2015-10-20 09:02:55 -07:00

35 lines
890 B
PHP

<?php
final class PhabricatorSearchOrderController
extends PhabricatorSearchBaseController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$engine_class = $request->getURIData('engine');
$request->validateCSRF();
$base_class = 'PhabricatorApplicationSearchEngine';
if (!is_subclass_of($engine_class, $base_class)) {
return new Aphront400Response();
}
$engine = newv($engine_class, array());
$engine->setViewer($viewer);
$queries = $engine->loadAllNamedQueries();
$queries = mpull($queries, null, 'getQueryKey');
$order = $request->getStrList('order');
$queries = array_select_keys($queries, $order) + $queries;
$sequence = 1;
foreach ($queries as $query) {
$query->setSequence($sequence++);
$query->save();
}
return id(new AphrontAjaxResponse());
}
}