Completed
Push — master ( d67f41...79042b )
by Adam
07:27
created

NewsCategoryFormBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAlias() 0 4 1
B buildForm() 0 24 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 NewsCategoryFormBuilder
20
 *
21
 * @author  Adam Piotrowski <[email protected]>
22
 */
23
class NewsCategoryFormBuilder extends AbstractFormBuilder
24
{
25
    public function getAlias(): string
26
    {
27
        return 'admin.news_category';
28
    }
29
    
30
    public function buildForm(FormInterface $form)
31
    {
32
        $requiredData = $form->addChild($this->getElement('nested_fieldset', [
33
            'name'  => 'required_data',
34
            'label' => 'common.fieldset.general',
35
        ]));
36
        
37
        $languageData = $requiredData->addChild($this->getElement('language_fieldset', [
38
            'name'        => 'translations',
39
            'label'       => 'common.fieldset.translations',
40
            'transformer' => $this->getRepositoryTransformer('translation', $this->get('news_category.repository')),
41
        ]));
42
        
43
        $languageData->addChild($this->getElement('text_field', [
44
            'name'  => 'name',
45
            'label' => 'common.label.name',
46
            'rules' => [
47
                $this->getRule('required'),
48
            ],
49
        ]));
50
        
51
        $form->addFilter($this->getFilter('trim'));
52
        $form->addFilter($this->getFilter('secure'));
53
    }
54
}
55