Completed
Pull Request — master (#91)
by Piotr
02:36
created

UserElement   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 53
c 0
b 0
f 0
wmc 6
lcom 1
cbo 5
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A initDataGrid() 0 4 1
A initDataSource() 0 4 1
A initForm() 0 4 1
A getId() 0 4 1
A getClassName() 0 4 1
1
<?php
2
3
namespace FSi\Bundle\AdminSecurityBundle\Doctrine\Admin;
4
5
use FSi\Bundle\AdminBundle\Doctrine\Admin\CRUDElement;
6
use FSi\Component\DataGrid\DataGridFactoryInterface;
7
use FSi\Component\DataSource\DataSourceFactoryInterface;
8
use Symfony\Component\Form\FormFactoryInterface;
9
10
class UserElement extends CRUDElement
11
{
12
    /**
13
     * @var string
14
     */
15
    private $userModel;
16
17
    public function __construct($options, $userModel)
18
    {
19
        parent::__construct($options);
20
        $this->userModel = $userModel;
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function initDataGrid(DataGridFactoryInterface $factory)
27
    {
28
        return $factory->createDataGrid('admin_security_user');
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function initDataSource(DataSourceFactoryInterface $factory)
35
    {
36
        return $factory->createDataSource('doctrine', ['entity' => $this->getClassName()])->setMaxResults(20);
0 ignored issues
show
Bug introduced by
The call to createDataSource() misses a required argument $name.

This check looks for function calls that miss required arguments.

Loading history...
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    protected function initForm(FormFactoryInterface $factory, $data = null)
43
    {
44
        return $factory->create('admin_user', $data);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function getId()
51
    {
52
        return 'admin_security_user';
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function getClassName()
59
    {
60
        return $this->userModel;
61
    }
62
}
63