GenericListElement   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 11
dl 0
loc 49
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setDataSourceFactory() 0 3 1
A createDataGrid() 0 3 1
A createDataSource() 0 3 1
A setDataGridFactory() 0 3 1
A getRoute() 0 3 1
A configureOptions() 0 7 1
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace FSi\Bundle\AdminBundle\Admin\CRUD;
13
14
use FSi\Bundle\AdminBundle\Admin\AbstractElement;
15
use FSi\Component\DataGrid\DataGridFactoryInterface;
16
use FSi\Component\DataGrid\DataGridInterface;
17
use FSi\Component\DataSource\DataSourceFactoryInterface;
18
use FSi\Component\DataSource\DataSourceInterface;
19
use Symfony\Component\OptionsResolver\OptionsResolver;
20
21
abstract class GenericListElement extends AbstractElement implements ListElement
22
{
23
    /**
24
     * @var DataSourceFactoryInterface
25
     */
26
    protected $datasourceFactory;
27
28
    /**
29
     * @var DataGridFactoryInterface
30
     */
31
    protected $datagridFactory;
32
33
    public function getRoute(): string
34
    {
35
        return 'fsi_admin_list';
36
    }
37
38
    public function configureOptions(OptionsResolver $resolver): void
39
    {
40
        $resolver->setDefaults([
41
            'template_list' => null,
42
        ]);
43
44
        $resolver->setAllowedTypes('template_list', ['null', 'string']);
45
    }
46
47
    public function setDataGridFactory(DataGridFactoryInterface $factory): void
48
    {
49
        $this->datagridFactory = $factory;
50
    }
51
52
    public function setDataSourceFactory(DataSourceFactoryInterface $factory): void
53
    {
54
        $this->datasourceFactory = $factory;
55
    }
56
57
    public function createDataGrid(): DataGridInterface
58
    {
59
        return $this->initDataGrid($this->datagridFactory);
60
    }
61
62
    public function createDataSource(): DataSourceInterface
63
    {
64
        return $this->initDataSource($this->datasourceFactory);
65
    }
66
67
    abstract protected function initDataGrid(DataGridFactoryInterface $factory): DataGridInterface;
68
69
    abstract protected function initDataSource(DataSourceFactoryInterface $factory): DataSourceInterface;
70
}
71