Completed
Pull Request — master (#30)
by Alexis
02:25
created

BaseBlockEntityAdmin::configureListFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 23
rs 9.0856
cc 1
eloc 15
nc 1
nop 1
1
<?php
2
3
namespace Alpixel\Bundle\CMSBundle\Admin;
4
5
use Sonata\AdminBundle\Datagrid\ListMapper;
6
use Sonata\AdminBundle\Form\FormMapper;
7
use Sonata\AdminBundle\Route\RouteCollection;
8
9
/**
10
 * @author Benjamin HUBERT <[email protected]>
11
 */
12
class BaseBlockEntityAdmin extends BaseAdmin
13
{
14
    protected $baseRouteName = 'alpixel_admin_cms_block';
15
    protected $baseRoutePattern = 'block';
16
    protected $datagridValues = [
17
        '_page'       => 1,
18
        '_sort_order' => 'DESC',
19
        '_sort_by'    => 'dateUpdated',
20
    ];
21
22
23
    protected function configureRoutes(RouteCollection $collection)
24
    {
25
        $collection->clearExcept(['list', 'delete', 'edit']);
26
        $collection->add('editContent', $this->getRouterIdParameter().'/edit/block');
27
    }
28
29
    protected function configureFormFields(FormMapper $formMapper)
30
    {
31
        $formMapper
32
            ->add('content', 'ckeditor', [
33
                'label'       => 'Contenu',
34
                'required'    => true,
35
                'config_name' => 'admin',
36
            ])
37
            ->end();
38
    }
39
40
    /**
41
     * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
42
     *
43
     * @return void
44
     */
45
    protected function configureListFields(ListMapper $listMapper)
46
    {
47
        $listMapper
48
            ->add('id')
49
            ->add('locale', null, [
50
                'label' => 'Langue',
51
            ])
52
            ->add('name', null, [
53
                'label' => 'Nom',
54
            ])
55
            ->add('dateCreated', null, [
56
                'label' => 'Date de création',
57
            ])
58
            ->add('dateUpdated', null, [
59
                'label' => 'Date d\'édition',
60
            ])
61
            ->add('_action', 'actions', [
62
                'actions' => [
63
                    'editContent' => ['template' => 'AlpixelCMSBundle:admin:fields/list__action_edit.html.twig'],
64
                    'delete'      => [],
65
                ],
66
            ]);
67
    }
68
}
69