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

AbstractNewsAdmin::preUpdate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Stfalcon\Bundle\EventBundle\Admin\AbstractClass;
4
5
use A2lix\TranslationFormBundle\Util\GedmoTranslatable;
6
use Sonata\AdminBundle\Admin\Admin;
7
use Sonata\AdminBundle\Form\FormMapper;
8
use Sonata\AdminBundle\Datagrid\ListMapper;
9
10
/**
11
 * Class AbstractNewsAdmin.
12
 */
13
abstract class AbstractNewsAdmin extends AbstractTranslateAdmin
14
{
15
    /**
16
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
17
     *
18
     * @return \Sonata\AdminBundle\Form\FormMapper
19
     */
20
    protected function configureFormFields(FormMapper $formMapper)
21
    {
22
        $localsRequiredService = $this->getConfigurationPool()->getContainer()->get('application_default.sonata.locales.required');
23
        $localOptions = $localsRequiredService->getLocalsRequiredArray();
24
        $localOptionsAllFalse = $localsRequiredService->getLocalsRequiredArray(false);
25
        $formMapper
26
            ->with('Переводы')
27
                ->add('translations', 'a2lix_translations_gedmo', [
28
                    'translatable_class' => $this->getClass(),
29
                    'fields' => [
30
                        'title' => [
31
                            'label' => 'title',
32
                            'locale_options' => $localOptions,
33
                        ],
34
                        'text' => [
35
                            'label' => 'текст',
36
                            'locale_options' => $localOptions,
37
                        ],
38
                        'preview' => [
39
                            'label' => 'preview',
40
                            'locale_options' => $localOptions,
41
                        ],
42
                        'metaKeywords' => [
43
                            'label' => 'metaKeywords',
44
                            'locale_options' => $localOptionsAllFalse,
45
                        ],
46
                        'metaDescription' => [
47
                            'label' => 'metaDescription',
48
                            'locale_options' => $localOptionsAllFalse,
49
                        ],
50
                    ],
51
                ])
52
            ->end()
53
            ->with('General')
54
                ->add('slug')
55
                ->add('created_at')
56
            ->end()
57
        ;
58
59
        return $formMapper;
60
    }
61
62
    /**
63
     * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
64
     *
65
     * @return \Sonata\AdminBundle\Datagrid\ListMapper
66
     */
67
    protected function configureListFields(ListMapper $listMapper)
68
    {
69
        $listMapper
70
            ->addIdentifier('slug')
71
            ->add('title')
72
            ->add('created_at');
73
74
        return $listMapper;
75
    }
76
}
77