Completed
Push — master ( 9e1211...19df0f )
by Benjamin
02:32
created

BaseNodeEntityAdmin::configureListFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 20
rs 9.4285
cc 1
eloc 13
nc 1
nop 1
1
<?php
2
3
namespace Alpixel\Bundle\CMSBundle\Admin;
4
5
use Sonata\AdminBundle\Admin\Admin;
6
use Sonata\AdminBundle\Datagrid\ListMapper;
7
use Sonata\AdminBundle\Form\FormMapper;
8
9
class BaseNodeEntityAdmin extends Admin
10
{
11
    protected function configureFormFields(FormMapper $formMapper)
12
    {
13
        $container = $this->getConfigurationPool()->getContainer();
14
15
        $realLocales = [];
16 View Code Duplication
        if($container->hasParameter('lunetics_locale.allowed_locales')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
            $locales = $container->getParameter('lunetics_locale.allowed_locales');
18
            foreach ($locales as $val) {
19
                $realLocales[$val] = $val;
20
            }
21
        } else {
22
            $realLocales['fr'] = 'fr';
23
        }
24
25
        $formMapper
26
            ->add('title', null, [
27
                'label' => 'Titre',
28
                'required' => true,
29
            ])
30
            ->add('content', 'ckeditor', [
31
                'label' => 'Contenu',
32
                'required' => true,
33
                'config_name' => 'admin',
34
            ])
35
            ->add('locale', 'choice', [
36
                'label' => 'Langue du contenu',
37
                'choices' => $realLocales,
38
                'required' => true,
39
            ])
40
            ->add('published', 'checkbox', [
41
                'label' => 'Publié',
42
                'required' => false,
43
            ]);
44
    }
45
}