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

ClientAdmin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 63
rs 10
wmc 4
lcom 0
cbo 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A configureFormFields() 0 10 1
A configureListFields() 0 15 1
A configureDatagridFilters() 0 6 1
A configureRoutes() 0 7 1
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
                    'lock' => array(
47
                        'template' => 'AppBundle:SwindlerLocked:swindlerLock.html.twig',
48
                    ),
49
                ],
50
            ])
51
        ;
52
    }
53
54
    /**
55
     * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper
56
     */
57
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
58
    {
59
        $datagridMapper
60
            ->add('ip')
61
        ;
62
    }
63
64
    /**
65
     * @param RouteCollection $collection
66
     */
67
    protected function configureRoutes(RouteCollection $collection)
68
    {
69
        $collection
70
            ->add('lock')
71
            ->add('unlock')
72
        ;
73
    }
74
}
75