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

BaseNodeEntityAdmin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 13
Bugs 4 Features 2
Metric Value
wmc 4
c 13
b 4
f 2
lcom 0
cbo 3
dl 0
loc 50
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A configureRoutes() 0 6 1
A configureMainFields() 0 13 1
A configureFormFields() 0 18 1
A showCustomURL() 0 4 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