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
|
|
|
|