|
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\Options; |
|
9
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Ease Admin configuration manipulation. |
|
13
|
|
|
*/ |
|
14
|
|
|
class AdminConfiguration extends Configuration implements ConfigurationInterface |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @var ApplicationConfiguration |
|
18
|
|
|
*/ |
|
19
|
|
|
protected $applicationConfiguration; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* AdminConfiguration constructor. |
|
23
|
|
|
* |
|
24
|
|
|
* @param ApplicationConfiguration $applicationConfiguration |
|
25
|
|
|
*/ |
|
26
|
17 |
|
public function __construct(ApplicationConfiguration $applicationConfiguration) |
|
27
|
|
|
{ |
|
28
|
17 |
|
parent::__construct(); |
|
29
|
|
|
|
|
30
|
17 |
|
$this->applicationConfiguration = $applicationConfiguration; |
|
31
|
17 |
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param OptionsResolver $resolver |
|
35
|
|
|
*/ |
|
36
|
17 |
|
public function configureOptions(OptionsResolver $resolver) |
|
37
|
|
|
{ |
|
38
|
|
|
// inherited routing configuration from global application configuration |
|
39
|
17 |
|
$routing = $this |
|
40
|
|
|
->applicationConfiguration |
|
41
|
17 |
|
->getParameter('routing'); |
|
42
|
|
|
|
|
43
|
|
|
// inherited max per page configuration |
|
44
|
17 |
|
$maxPerPage = $this |
|
45
|
|
|
->applicationConfiguration |
|
46
|
17 |
|
->getParameter('max_per_page'); |
|
47
|
|
|
|
|
48
|
|
|
// optional options |
|
49
|
17 |
|
$resolver->setDefaults([ |
|
50
|
|
|
'actions' => [ |
|
51
|
17 |
|
'list' => [], |
|
52
|
17 |
|
'create' => [], |
|
53
|
17 |
|
'edit' => [], |
|
54
|
17 |
|
'delete' => [], |
|
55
|
17 |
|
], |
|
56
|
17 |
|
'batch' => true, |
|
57
|
17 |
|
'routing_url_pattern' => $routing['url_pattern'], |
|
58
|
17 |
|
'routing_name_pattern' => $routing['name_pattern'], |
|
59
|
17 |
|
'controller' => 'LAGAdminBundle:CRUD', |
|
60
|
17 |
|
'max_per_page' => $maxPerPage, |
|
61
|
17 |
|
'data_provider' => null, |
|
62
|
17 |
|
]); |
|
63
|
|
|
// required options |
|
64
|
17 |
|
$resolver->setRequired([ |
|
65
|
17 |
|
'entity', |
|
66
|
17 |
|
'form', |
|
67
|
17 |
|
]); |
|
68
|
|
|
|
|
69
|
17 |
|
$resolver->setDefault('menu', [ |
|
70
|
|
|
'main' => [ |
|
71
|
|
|
'action' => 'list' |
|
72
|
17 |
|
] |
|
73
|
17 |
|
]); |
|
74
|
|
|
|
|
75
|
17 |
|
$resolver->setNormalizer('actions', function(Options $options, $actions) { |
|
76
|
17 |
|
$normalizedActions = []; |
|
77
|
|
|
|
|
78
|
17 |
|
foreach ($actions as $name => $action) { |
|
79
|
|
|
|
|
80
|
17 |
|
if ($action === null) { |
|
81
|
|
|
$action = []; |
|
82
|
|
|
} |
|
83
|
17 |
|
$normalizedActions[$name] = $action; |
|
84
|
17 |
|
} |
|
85
|
|
|
|
|
86
|
17 |
|
return $normalizedActions; |
|
87
|
17 |
|
}); |
|
88
|
17 |
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|