Completed
Push — master ( 0fb6c2...a0d538 )
by Adam
19:02
created

PageLayoutFormBuilder::buildForm()   B

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 27
Code Lines 18

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 18
nc 1
nop 1
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\CmsBundle\Form\Admin;
14
15
use WellCommerce\Bundle\CoreBundle\Form\AbstractFormBuilder;
16
use WellCommerce\Component\Form\Elements\FormInterface;
17
18
/**
19
 * Class PageLayoutFormBuilder
20
 *
21
 * @author  Adam Piotrowski <[email protected]>
22
 */
23
class PageLayoutFormBuilder extends AbstractFormBuilder
24
{
25
    public function getAlias(): string
26
    {
27
        return 'admin.page_layout';
28
    }
29
    
30
    public function buildForm(FormInterface $form)
31
    {
32
        $mainData = $form->addChild($this->getElement('nested_fieldset', [
33
            'name'  => 'main_data',
34
            'label' => 'common.fieldset.general',
35
        ]));
36
        
37
        $producer = $mainData->addChild($this->getElement('select', [
38
            'name'        => 'producer',
39
            'label'       => 'common.label.producer',
40
            'options'     => $this->get('producer.dataset.admin')->getResult('select', ['limit' => 10000]),
41
            'transformer' => $this->getRepositoryTransformer('entity', $this->get('producer.repository')),
42
        ]));
43
        
44
        $mainData->addChild($this->getElement('select', [
45
            'name'         => 'producer_collection',
46
            'label'        => $this->trans('common.label.producer_collection'),
47
            'transformer'  => $this->getRepositoryTransformer('entity', $this->get('producer_collection.repository')),
48
            'dependencies' => [
49
                $this->getDependency('exchange_options', [
50
                    'field'              => $producer,
51
                    'load_options_route' => 'admin.producer_collection.get_collections_by_producer_id.ajax.index',
52
                    'form'               => $form,
53
                ]),
54
            ],
55
        ]));
56
    }
57
}
58