Completed
Pull Request — master (#33)
by Benjamin
02:29
created

BaseNodeEntityAdmin::configureListFields()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 30
rs 8.8571
cc 1
eloc 20
nc 1
nop 1
1
<?php
2
3
namespace Alpixel\Bundle\CMSBundle\Admin;
4
5
use Alpixel\Bundle\CMSBundle\Form\DateTimeSingleType;
6
use Sonata\AdminBundle\Form\FormMapper;
7
use Sonata\AdminBundle\Route\RouteCollection;
8
9
abstract class BaseNodeEntityAdmin extends BaseAdmin
10
{
11
12
    protected function configureRoutes(RouteCollection $collection)
13
    {
14
        $collection->clearExcept(['add', 'edit', 'delete']);
15
        $collection->add('see', $this->getRouterIdParameter() . '/see');
16
        $collection->add('createTranslation', $this->getRouterIdParameter() . '/translate');
17
    }
18
19
    protected function configureMainFields(FormMapper $formMapper)
20
    {
21
        $formMapper
22
            ->add('title', null, [
23
                'label' => 'Titre',
24
                'required' => true,
25
            ])
26
            ->add('content', 'ckeditor', [
27
                'label' => 'Contenu',
28
                'required' => false,
29
                'config_name' => 'admin',
30
            ]);
31
    }
32
33
34
    protected function configureFormFields(FormMapper $formMapper)
35
    {
36
        self::configureMainFields($formMapper);
37
38
        $formMapper
39
            ->add('locale', 'choice', [
40
                'label' => 'Langue du contenu',
41
                'choices' => $this->getRealLocales(),
42
                'required' => true,
43
            ])
44
            ->add('dateCreated', DateTimeSingleType::class, [
45
                'label' => 'Date de création',
46
            ])
47
            ->add('published', 'checkbox', [
48
                'label' => 'Publié',
49
                'required' => false,
50
            ]);
51
    }
52
53
54
    public function showCustomURL($object = null)
0 ignored issues
show
Unused Code introduced by
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
55
    {
56
        return null;
57
    }
58
}
59