Passed
Pull Request — master (#494)
by Andrew
04:59
created

CategoryAdmin::removeNullTranslate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
namespace Stfalcon\Bundle\SponsorBundle\Admin;
4
5
use Sonata\AdminBundle\Form\FormMapper;
6
use Sonata\AdminBundle\Datagrid\ListMapper;
7
use Stfalcon\Bundle\EventBundle\Admin\AbstractClass\AbstractTranslateAdmin;
8
9
/**
10
 * SponsorAdmin Class.
11
 */
12
class CategoryAdmin extends AbstractTranslateAdmin
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    protected function configureListFields(ListMapper $listMapper)
18
    {
19
        $listMapper
20
            ->addIdentifier('id')
21
            ->addIdentifier('name', null, ['label' => 'Название'])
22
            ->add('sortOrder', null, ['label' => 'Номер сортировки'])
23
            ->add('isWideContainer', null, ['label' => 'Главная категория'])
24
            ->add('_action', 'actions', [
25
                'label' => 'Действие',
26
                'actions' => [
27
                    'edit' => [],
28
                    'delete' => [],
29
                ],
30
            ]);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected function configureFormFields(FormMapper $formMapper)
37
    {
38
        $localsRequiredService = $this->getConfigurationPool()->getContainer()->get('application_default.sonata.locales.required');
39
        $localOptions = $localsRequiredService->getLocalsRequiredArray();
40
        $formMapper
41
            ->with('Переводы')
42
                ->add(
43
                    'translations',
44
                    'a2lix_translations_gedmo',
45
                    [
46
                        'translatable_class' => $this->getClass(),
47
                        'label' => 'Переводы',
48
                        'fields' => [
49
                            'name' => [
50
                                'label' => 'Название',
51
                                'locale_options' => $localOptions,
52
                            ],
53
                        ],
54
                    ]
55
                )
56
            ->end()
57
            ->with('Общие')
58
                ->add('isWideContainer', null, ['required' => false, 'label' => 'Главная категория (широкий контейнер)'])
59
                ->add('sortOrder', null, ['label' => 'Номер сортировки'])
60
            ->end();
61
    }
62
}
63