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

ClientAdmin::configureFormFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 10
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
                    '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