Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / search / controller / PhabricatorSearchOrderController.php
blobe5f7887473db3aed34e2a1fa9901fb6ca2ac1395
1 <?php
3 final class PhabricatorSearchOrderController
4 extends PhabricatorSearchBaseController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
8 $engine_class = $request->getURIData('engine');
10 $request->validateCSRF();
12 $base_class = 'PhabricatorApplicationSearchEngine';
13 if (!is_subclass_of($engine_class, $base_class)) {
14 return new Aphront400Response();
17 $engine = newv($engine_class, array());
18 $engine->setViewer($viewer);
20 $queries = $engine->loadAllNamedQueries();
21 $queries = mpull($queries, null, 'getQueryKey');
23 $order = $request->getStrList('order');
24 $queries = array_select_keys($queries, $order) + $queries;
26 $sequence = 1;
27 foreach ($queries as $query) {
28 $query->setSequence($sequence++);
29 $query->save();
32 return id(new AphrontAjaxResponse());