Completed
Pull Request — master (#3)
by Alexis
06:28 queued 03:56
created

MenuAdmin::configureListFields()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 24
rs 8.9713
cc 1
eloc 15
nc 1
nop 1
1
<?php
2
3
namespace Alpixel\Bundle\MenuBundle\Controller\Admin\CRUD;
4
5
use Sonata\AdminBundle\Admin\Admin;
6
use Sonata\AdminBundle\Datagrid\ListMapper;
7
use Sonata\AdminBundle\Form\FormMapper;
8
use Sonata\AdminBundle\Route\RouteCollection;
9
10
class MenuAdmin extends Admin
11
{
12
    public function createQuery($context = 'list')
13
    {
14
        $query = parent::createQuery($context);
15
        $query->addOrderBy($query->getRootAlias().'.locale', 'ASC');
16
17
        return $query;
18
    }
19
20
    protected function configureRoutes(RouteCollection $collection)
21
    {
22
        $collection->clearExcept(['list']);
23
        $collection->add('item', $this->getRouterIdParameter().'/item');
24
    }
25
26
    protected function configureFormFields(FormMapper $formMapper)
27
    {
28
        $formMapper
29
            ->add('name', null, array(
30
                'label'    => 'Label',
31
                'required' => true,
32
            ))
33
            ->add('locale', 'choice', array( //@Todo Replace choices by $container->getParameter('lunetics_locale.allowed_locales');
0 ignored issues
show
Unused Code Comprehensibility introduced by
44% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
34
                'label'   => 'Langue',
35
                'choices' => array(
36
                    'fr' => 'fr',
37
                    'en' => 'en',
38
                    'it' => 'it',
39
                ),
40
                'required' => true,
41
            ))
42
        ;
43
    }
44
45
    protected function configureListFields(ListMapper $listMapper)
46
    {
47
        $listMapper
48
            ->add('machineName', null, array(
49
                'label'    => 'Nom de la machine',
50
                'required' => true,
51
            ))
52
            ->add('name', null, array(
53
                'label'    => 'Label',
54
                'required' => true,
55
            ))
56
            ->add('locale', null, array(
57
                'label'    => 'Langue',
58
                'required' => true,
59
            ))
60
            ->add('_action', 'actions', array(
61
                'actions' => array(
62
                    'item' => array(
63
                        'template' => 'AlpixelMenuBundle:CRUD:list__action_item.html.twig'
64
                    )
65
                )
66
            ))
67
        ;
68
    }
69
}
70