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

AbstractPageAdmin::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\EventBundle\Admin\AbstractClass;
4
5
use Sonata\AdminBundle\Form\FormMapper;
6
use Sonata\AdminBundle\Datagrid\ListMapper;
7
8
/**
9
 * Class AbstractPageAdmin.
10
 */
11
abstract class AbstractPageAdmin extends AbstractTranslateAdmin
12
{
13
    /**
14
     * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
15
     *
16
     * @return \Sonata\AdminBundle\Datagrid\ListMapper
17
     */
18
    protected function configureListFields(ListMapper $listMapper)
19
    {
20
        $listMapper
21
            ->addIdentifier('slug')
22
            ->add('title', null, ['label' => 'Название']);
23
24
        return $listMapper;
25
    }
26
27
    /**
28
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
29
     *
30
     * @return \Sonata\AdminBundle\Form\FormMapper
31
     */
32
    protected function configureFormFields(FormMapper $formMapper)
33
    {
34
        $localsRequiredService = $this->getConfigurationPool()->getContainer()->get('application_default.sonata.locales.required');
35
        $localOptions = $localsRequiredService->getLocalsRequiredArray();
36
        $localOptionsAllFalse = $localsRequiredService->getLocalsRequiredArray(false);
37
        $formMapper
38
            ->with('Переводы')
39
                ->add('translations', 'a2lix_translations_gedmo', [
40
                    'translatable_class' => $this->getClass(),
41
                    'fields' => [
42
                        'title' => [
43
                            'label' => 'Название',
44
                            'locale_options' => $localOptions,
45
                        ],
46
                        'text' => [
47
                            'label' => 'текст',
48
                            'locale_options' => $localOptions,
49
                        ],
50
                        'metaKeywords' => [
51
                            'label' => 'metaKeywords',
52
                            'locale_options' => $localOptionsAllFalse,
53
                        ],
54
                        'metaDescription' => [
55
                            'label' => 'metaDescription',
56
                            'locale_options' => $localOptionsAllFalse,
57
                        ],
58
                    ],
59
                ])
60
            ->end()
61
            ->with('Общие')
62
                ->add('slug')
63
            ->end()
64
        ;
65
66
        return $formMapper;
67
    }
68
}
69