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\Service\Layout\Configurator; |
14
|
|
|
|
15
|
|
|
use WellCommerce\Bundle\CatalogBundle\Controller\Box\CategoryMenuBoxController; |
16
|
|
|
use WellCommerce\Bundle\CatalogBundle\DataSet\Admin\CategoryDataSet; |
17
|
|
|
use WellCommerce\Bundle\CoreBundle\Layout\Configurator\AbstractLayoutBoxConfigurator; |
18
|
|
|
use WellCommerce\Component\Form\Elements\FormInterface; |
19
|
|
|
use WellCommerce\Component\Form\FormBuilderInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class CategoryMenuBoxConfigurator |
23
|
|
|
* |
24
|
|
|
* @author Adam Piotrowski <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
final class CategoryMenuBoxConfigurator extends AbstractLayoutBoxConfigurator |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var CategoryDataSet |
30
|
|
|
*/ |
31
|
|
|
private $dataSet; |
32
|
|
|
|
33
|
|
|
public function __construct(CategoryMenuBoxController $controller, CategoryDataSet $dataSet) |
34
|
|
|
{ |
35
|
|
|
$this->controller = $controller; |
36
|
|
|
$this->dataSet = $dataSet; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function getType(): string |
40
|
|
|
{ |
41
|
|
|
return 'CategoryMenu'; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function addFormFields(FormBuilderInterface $builder, FormInterface $form, $defaults) |
45
|
|
|
{ |
46
|
|
|
$fieldset = $this->getFieldset($builder, $form); |
47
|
|
|
$accessor = $this->getPropertyAccessor(); |
48
|
|
|
|
49
|
|
|
$fieldset->addChild($builder->getElement('tip', [ |
50
|
|
|
'tip' => 'Choose categories which should be not visible in box.', |
51
|
|
|
])); |
52
|
|
|
|
53
|
|
|
$exclude = $fieldset->addChild($builder->getElement('tree', [ |
54
|
|
|
'name' => 'exclude', |
55
|
|
|
'label' => 'category.label.exclude', |
56
|
|
|
'choosable' => false, |
57
|
|
|
'selectable' => true, |
58
|
|
|
'sortable' => false, |
59
|
|
|
'clickable' => false, |
60
|
|
|
'items' => $this->dataSet->getResult('flat_tree'), |
61
|
|
|
])); |
62
|
|
|
|
63
|
|
|
$exclude->setValue($accessor->getValue($defaults, '[exclude]')); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|