1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* WellCommerce Open-Source E-Commerce Platform |
4
|
|
|
* |
5
|
|
|
* This file is part of the WellCommerce package. |
6
|
|
|
* |
7
|
|
|
* (c) Adam Piotrowski <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, |
10
|
|
|
* please view the LICENSE file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace WellCommerce\Bundle\CatalogBundle\Controller\Admin; |
14
|
|
|
|
15
|
|
|
use WellCommerce\Bundle\CoreBundle\Controller\Admin\AbstractAdminController; |
16
|
|
|
use Symfony\Component\HttpFoundation\Request; |
17
|
|
|
use Symfony\Component\HttpFoundation\Response; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class ProducerCollectionController |
21
|
|
|
* |
22
|
|
|
* @author Rafał Martonik <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class ProducerCollectionController extends AbstractAdminController |
25
|
|
|
{ |
26
|
|
|
public function ajaxGetCollectionsByProducer(Request $request) : Response |
27
|
|
|
{ |
28
|
|
|
if (!$request->isXmlHttpRequest()) { |
29
|
|
|
return $this->redirectToAction('index'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
$producerId = (int)$request->request->get('producerId'); |
33
|
|
|
$producerCollectionOptions = []; |
34
|
|
|
$producerCollections = $this->getManager()->getRepository()->findBy(['producer' => $producerId]); |
35
|
|
|
$producerCollectionOptions[0] = [ |
36
|
|
|
'sValue' => 0, |
37
|
|
|
'sLabel' => $this->trans('common.label.none'), |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
foreach ($producerCollections AS $key => $producerCollection) { |
41
|
|
|
$producerCollectionOptions[$key + 1] = [ |
42
|
|
|
'sValue' => $producerCollection->getId(), |
43
|
|
|
'sLabel' => $producerCollection->translate()->getName(), |
44
|
|
|
]; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
return $this->jsonResponse( |
48
|
|
|
$producerCollectionOptions |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|