-
Notifications
You must be signed in to change notification settings - Fork 0
/
FilterReorderController.php
63 lines (52 loc) · 1.95 KB
/
FilterReorderController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/
namespace Spryker\Zed\ProductSearch\Communication\Controller;
use Spryker\Zed\Kernel\Communication\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
/**
* @method \Spryker\Zed\ProductSearch\Business\ProductSearchFacadeInterface getFacade()
* @method \Spryker\Zed\ProductSearch\Communication\ProductSearchCommunicationFactory getFactory()
* @method \Spryker\Zed\ProductSearch\Persistence\ProductSearchQueryContainerInterface getQueryContainer()
* @method \Spryker\Zed\ProductSearch\Persistence\ProductSearchRepositoryInterface getRepository()
*/
class FilterReorderController extends AbstractController
{
/**
* @var string
*/
public const PARAM_FILTER_LIST = 'filter_list';
/**
* @return array
*/
public function indexAction()
{
$productSearchAttributes = $this->getFacade()->getProductSearchAttributeList();
return $this->viewResponse([
'productSearchAttributes' => $productSearchAttributes,
]);
}
/**
* @param \Symfony\Component\HttpFoundation\Request $request
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function saveAction(Request $request)
{
/** @var array $filterList */
$filterList = $request->request
->all(static::PARAM_FILTER_LIST);
if (!$filterList) {
return $this->jsonResponse();
}
$sortedProductSearchAttributeList = $this
->getFactory()
->createSortedProductSearchTransferListMapper()
->createList($filterList);
$this->getFacade()->updateProductSearchAttributeOrder($sortedProductSearchAttributeList);
$this->getFacade()->touchProductSearchConfigExtension();
return $this->jsonResponse();
}
}