1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LAG\AdminBundle\Admin\Configuration; |
4
|
|
|
|
5
|
|
|
use LAG\AdminBundle\Application\Configuration\ApplicationConfiguration; |
6
|
|
|
use LAG\AdminBundle\Configuration\Configuration; |
7
|
|
|
use LAG\AdminBundle\Configuration\ConfigurationInterface; |
8
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Ease Admin configuration manipulation |
12
|
|
|
*/ |
13
|
|
|
class AdminConfiguration extends Configuration implements ConfigurationInterface |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var ApplicationConfiguration |
17
|
|
|
*/ |
18
|
|
|
protected $applicationConfiguration; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* AdminConfiguration constructor. |
22
|
|
|
* |
23
|
|
|
* @param ApplicationConfiguration $applicationConfiguration |
24
|
|
|
*/ |
25
|
|
|
public function __construct(ApplicationConfiguration $applicationConfiguration) |
26
|
|
|
{ |
27
|
|
|
parent::__construct(); |
28
|
|
|
|
29
|
|
|
$this->applicationConfiguration = $applicationConfiguration; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param OptionsResolver $resolver |
34
|
|
|
*/ |
35
|
|
|
public function configureOptions(OptionsResolver $resolver) |
36
|
|
|
{ |
37
|
|
|
// inherited routing configuration from global application configuration |
38
|
|
|
$routing = $this |
39
|
|
|
->applicationConfiguration |
40
|
|
|
->getParameter('routing'); |
41
|
|
|
|
42
|
|
|
// inherited max per page configuration |
43
|
|
|
$maxPerPage = $this |
44
|
|
|
->applicationConfiguration |
45
|
|
|
->getParameter('max_per_page'); |
46
|
|
|
|
47
|
|
|
// optional options |
48
|
|
|
$resolver->setDefaults([ |
49
|
|
|
'actions' => [ |
50
|
|
|
'list' => [], |
51
|
|
|
'create' => [], |
52
|
|
|
'edit' => [], |
53
|
|
|
'delete' => [], |
54
|
|
|
], |
55
|
|
|
'batch' => true, |
56
|
|
|
'manager' => 'LAG\AdminBundle\Manager\GenericManager', |
57
|
|
|
'routing_url_pattern' => $routing['url_pattern'], |
58
|
|
|
'routing_name_pattern' => $routing['name_pattern'], |
59
|
|
|
'controller' => 'LAGAdminBundle:CRUD', |
60
|
|
|
'max_per_page' => $maxPerPage, |
61
|
|
|
'data_provider' => null, |
62
|
|
|
]); |
63
|
|
|
// required options |
64
|
|
|
$resolver->setRequired([ |
65
|
|
|
'entity', |
66
|
|
|
'form', |
67
|
|
|
]); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|