Completed
Pull Request — master (#144)
by
unknown
13:51
created

ClientAdmin::configureRoutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
rs 9.4285
c 1
b 1
f 0
1
<?php
2
3
namespace AppBundle\Admin;
4
5
use AppBundle\Entity\Client;
6
use Sonata\AdminBundle\Admin\Admin;
7
use Sonata\AdminBundle\Datagrid\ListMapper;
8
use Sonata\AdminBundle\Datagrid\DatagridMapper;
9
use Sonata\AdminBundle\Form\FormMapper;
10
use Sonata\AdminBundle\Route\RouteCollection;
11
12
class ClientAdmin extends Admin
13
{
14
    protected $baseRouteName = 'AppBundle\Entity\Client';
15
    protected $baseRoutePattern = 'Client';
16
    protected $datagridValues = [
17
        '_sort_order' => 'DESC',
18
        '_sort_by' => 'id',
19
    ];
20
21
    /**
22
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
23
     */
24
    protected function configureFormFields(FormMapper $formMapper)
25
    {
26
        $formMapper
27
            ->with('Swindler', ['class' => 'col-lg-12'])
28
            ->add('ip', 'text', ['attr' => ['readonly' => true]])
29
             ->add('countAttempts', 'text', ['attr' => ['readonly' => true]])
30
            ->add('banned', 'text', ['attr' => ['readonly' => true]])
31
            ->end()
32
        ;
33
    }
34
35
    /**
36
     * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
37
     */
38
    protected function configureListFields(ListMapper $listMapper)
39
    {
40
        $listMapper
41
            ->add('ip')
42
            ->add('countAttempts')
43
            ->add('banned')
44
            ->add('_action', 'actions', [
45
                'actions' => [
46
                    'delete' => [],
47
                    'lock' => array(
48
                        'template' => 'AppBundle:SwindlerLocked:swindlerLock.html.twig',
49
                    ),
50
                ],
51
            ])
52
        ;
53
    }
54
55
    /**
56
     * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper
57
     */
58
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
59
    {
60
        $datagridMapper
61
            ->add('ip')
62
        ;
63
    }
64
65
    /**
66
     * @param RouteCollection $collection
67
     */
68
    protected function configureRoutes(RouteCollection $collection)
69
    {
70
        $collection
71
            ->add('lock')
72
            ->add('unlock')
73
        ;
74
    }
75
}
76