@@ -54,19 +54,19 @@ private function setupChainRouter(array $config, ContainerBuilder $container, Lo
54
54
// add the routers defined in the configuration mapping
55
55
$ router = $ container ->getDefinition ('cmf_routing.router ' );
56
56
foreach ($ config ['chain ' ]['routers_by_id ' ] as $ id => $ priority ) {
57
- $ router ->addMethodCall ('add ' , array ( new Reference ($ id ), trim ($ priority )) );
57
+ $ router ->addMethodCall ('add ' , [ new Reference ($ id ), trim ($ priority )] );
58
58
}
59
59
}
60
60
61
61
private function setupFormTypes (array $ config , ContainerBuilder $ container , LoaderInterface $ loader )
62
62
{
63
63
$ loader ->load ('form-type.xml ' );
64
64
65
- if (isset ( $ config [ 'dynamic ' ] )) {
65
+ if (array_key_exists ( 'dynamic ' , $ config )) {
66
66
$ routeTypeTypeDefinition = $ container ->getDefinition ('cmf_routing.route_type_form_type ' );
67
67
68
68
foreach (array_keys ($ config ['dynamic ' ]['controllers_by_type ' ]) as $ routeType ) {
69
- $ routeTypeTypeDefinition ->addMethodCall ('addRouteType ' , array ( $ routeType) );
69
+ $ routeTypeTypeDefinition ->addMethodCall ('addRouteType ' , [ $ routeType] );
70
70
}
71
71
}
72
72
}
@@ -83,7 +83,7 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
83
83
$ loader ->load ('routing-dynamic.xml ' );
84
84
85
85
// strip whitespace (XML support)
86
- foreach (array ( 'controllers_by_type ' , 'controllers_by_class ' , 'templates_by_class ' , 'route_filters_by_id ' ) as $ option ) {
86
+ foreach ([ 'controllers_by_type ' , 'controllers_by_class ' , 'templates_by_class ' , 'route_filters_by_id ' ] as $ option ) {
87
87
$ config [$ option ] = array_map ('trim ' , $ config [$ option ]);
88
88
}
89
89
@@ -98,7 +98,7 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
98
98
throw new InvalidConfigurationException ('It makes no sense to activate auto_locale_pattern when no locales are configured. ' );
99
99
}
100
100
101
- $ this ->configureParameters ($ container , $ config , array (
101
+ $ this ->configureParameters ($ container , $ config , [
102
102
'generic_controller ' => 'generic_controller ' ,
103
103
'controllers_by_type ' => 'controllers_by_type ' ,
104
104
'controllers_by_class ' => 'controllers_by_class ' ,
@@ -108,7 +108,7 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
108
108
'limit_candidates ' => 'dynamic.limit_candidates ' ,
109
109
'locales ' => 'dynamic.locales ' ,
110
110
'auto_locale_pattern ' => 'dynamic.auto_locale_pattern ' ,
111
- ) );
111
+ ] );
112
112
113
113
$ hasProvider = false ;
114
114
$ hasContentRepository = false ;
@@ -118,7 +118,7 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
118
118
}
119
119
120
120
if ($ config ['persistence ' ]['orm ' ]['enabled ' ]) {
121
- $ this ->loadOrmProvider ($ config ['persistence ' ]['orm ' ], $ loader , $ container , $ locales , $ config ['match_implicit_locale ' ]);
121
+ $ this ->loadOrmProvider ($ config ['persistence ' ]['orm ' ], $ loader , $ container , $ config ['match_implicit_locale ' ]);
122
122
$ hasProvider = $ hasContentRepository = true ;
123
123
}
124
124
@@ -139,27 +139,27 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
139
139
// content repository is optional
140
140
if ($ hasContentRepository ) {
141
141
$ generator = $ container ->getDefinition ('cmf_routing.generator ' );
142
- $ generator ->addMethodCall ('setContentRepository ' , array ( new Reference ('cmf_routing.content_repository ' )) );
142
+ $ generator ->addMethodCall ('setContentRepository ' , [ new Reference ('cmf_routing.content_repository ' )] );
143
143
$ container ->getDefinition ('cmf_routing.enhancer.content_repository ' )
144
- ->addTag ('dynamic_router_route_enhancer ' , array ( 'priority ' => 100 ) );
144
+ ->addTag ('dynamic_router_route_enhancer ' , [ 'priority ' => 100 ] );
145
145
}
146
146
147
147
$ dynamic = $ container ->getDefinition ('cmf_routing.dynamic_router ' );
148
148
149
149
// if any mappings are defined, set the respective route enhancer
150
150
if (count ($ config ['controllers_by_type ' ]) > 0 ) {
151
151
$ container ->getDefinition ('cmf_routing.enhancer.controllers_by_type ' )
152
- ->addTag ('dynamic_router_route_enhancer ' , array ( 'priority ' => 60 ) );
152
+ ->addTag ('dynamic_router_route_enhancer ' , [ 'priority ' => 60 ] );
153
153
}
154
154
155
155
if (count ($ config ['controllers_by_class ' ]) > 0 ) {
156
156
$ container ->getDefinition ('cmf_routing.enhancer.controllers_by_class ' )
157
- ->addTag ('dynamic_router_route_enhancer ' , array ( 'priority ' => 50 ) );
157
+ ->addTag ('dynamic_router_route_enhancer ' , [ 'priority ' => 50 ] );
158
158
}
159
159
160
160
if (count ($ config ['templates_by_class ' ]) > 0 ) {
161
161
$ container ->getDefinition ('cmf_routing.enhancer.templates_by_class ' )
162
- ->addTag ('dynamic_router_route_enhancer ' , array ( 'priority ' => 40 ) );
162
+ ->addTag ('dynamic_router_route_enhancer ' , [ 'priority ' => 40 ] );
163
163
164
164
/*
165
165
* The CoreBundle prepends the controller from ContentBundle if the
@@ -174,7 +174,7 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
174
174
}
175
175
176
176
// if the content class defines the template, we also need to make sure we use the generic controller for those routes
177
- $ controllerForTemplates = array () ;
177
+ $ controllerForTemplates = [] ;
178
178
foreach ($ config ['templates_by_class ' ] as $ key => $ value ) {
179
179
$ controllerForTemplates [$ key ] = $ config ['generic_controller ' ];
180
180
}
@@ -183,31 +183,31 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
183
183
$ definition ->replaceArgument (2 , $ controllerForTemplates );
184
184
185
185
$ container ->getDefinition ('cmf_routing.enhancer.controller_for_templates_by_class ' )
186
- ->addTag ('dynamic_router_route_enhancer ' , array ( 'priority ' => 30 ) );
186
+ ->addTag ('dynamic_router_route_enhancer ' , [ 'priority ' => 30 ] );
187
187
}
188
188
189
189
if (null !== $ config ['generic_controller ' ] && $ defaultController !== $ config ['generic_controller ' ]) {
190
190
$ container ->getDefinition ('cmf_routing.enhancer.explicit_template ' )
191
- ->addTag ('dynamic_router_route_enhancer ' , array ( 'priority ' => 10 ) );
191
+ ->addTag ('dynamic_router_route_enhancer ' , [ 'priority ' => 10 ] );
192
192
}
193
193
194
194
if (null !== $ defaultController ) {
195
195
$ container ->getDefinition ('cmf_routing.enhancer.default_controller ' )
196
- ->addTag ('dynamic_router_route_enhancer ' , array ( 'priority ' => -100 ) );
196
+ ->addTag ('dynamic_router_route_enhancer ' , [ 'priority ' => -100 ] );
197
197
}
198
198
199
199
if (count ($ config ['route_filters_by_id ' ]) > 0 ) {
200
200
$ matcher = $ container ->getDefinition ('cmf_routing.nested_matcher ' );
201
201
202
202
foreach ($ config ['route_filters_by_id ' ] as $ id => $ priority ) {
203
- $ matcher ->addMethodCall ('addRouteFilter ' , array ( new Reference ($ id ), $ priority) );
203
+ $ matcher ->addMethodCall ('addRouteFilter ' , [ new Reference ($ id ), $ priority] );
204
204
}
205
205
}
206
206
207
207
$ dynamic ->replaceArgument (2 , new Reference ($ config ['url_generator ' ]));
208
208
}
209
209
210
- private function loadPhpcrProvider ($ config , XmlFileLoader $ loader , ContainerBuilder $ container , array $ locales , $ matchImplicitLocale )
210
+ private function loadPhpcrProvider (array $ config , LoaderInterface $ loader , ContainerBuilder $ container , array $ locales , $ matchImplicitLocale )
211
211
{
212
212
$ loader ->load ('provider-phpcr.xml ' );
213
213
@@ -222,29 +222,17 @@ private function loadPhpcrProvider($config, XmlFileLoader $loader, ContainerBuil
222
222
} elseif (!$ matchImplicitLocale ) {
223
223
// remove all but the prefixes configuration from the service definition.
224
224
$ definition = $ container ->getDefinition ('cmf_routing.phpcr_candidates_prefix ' );
225
- $ definition ->setArguments (array ( $ definition ->getArgument (0 )) );
225
+ $ definition ->setArguments ([ $ definition ->getArgument (0 )] );
226
226
}
227
227
228
- if ($ config ['enable_initializer ' ]) {
229
- $ this ->loadInitializer ($ config , $ loader , $ container );
228
+ if (true === $ config ['enable_initializer ' ]) {
229
+ $ this ->loadInitializer ($ loader , $ container );
230
230
}
231
231
}
232
232
233
- /**
234
- * @param array $config
235
- * @param XmlFileLoader $loader
236
- * @param ContainerBuilder $container
237
- */
238
- private function loadInitializer ($ config , XmlFileLoader $ loader , ContainerBuilder $ container )
233
+ private function loadInitializer (LoaderInterface $ loader , ContainerBuilder $ container )
239
234
{
240
- $ initializedBasepaths = array ();
241
- if ('auto ' === $ config ['enable_initializer ' ] && empty ($ initializedBasepaths )) {
242
- return ;
243
- }
244
-
245
- if (true === $ config ['enable_initializer ' ] && empty ($ initializedBasepaths )) {
246
- $ initializedBasepaths = $ container ->getParameter ($ this ->getAlias ().'.dynamic.persistence.phpcr.route_basepaths ' );
247
- }
235
+ $ initializedBasepaths = $ container ->getParameter ($ this ->getAlias ().'.dynamic.persistence.phpcr.route_basepaths ' );
248
236
249
237
$ container ->setParameter (
250
238
$ this ->getAlias ().'.dynamic.persistence.phpcr.initialized_basepaths ' ,
@@ -254,7 +242,7 @@ private function loadInitializer($config, XmlFileLoader $loader, ContainerBuilde
254
242
$ loader ->load ('initializer-phpcr.xml ' );
255
243
}
256
244
257
- private function loadOrmProvider ($ config , XmlFileLoader $ loader , ContainerBuilder $ container , $ matchImplicitLocale )
245
+ private function loadOrmProvider (array $ config , LoaderInterface $ loader , ContainerBuilder $ container , $ matchImplicitLocale )
258
246
{
259
247
$ loader ->load ('provider-orm.xml ' );
260
248
@@ -269,7 +257,7 @@ private function loadOrmProvider($config, XmlFileLoader $loader, ContainerBuilde
269
257
270
258
if (!$ matchImplicitLocale ) {
271
259
// remove the locales argument from the candidates
272
- $ container ->getDefinition ('cmf_routing.orm_candidates ' )->setArguments (array () );
260
+ $ container ->getDefinition ('cmf_routing.orm_candidates ' )->setArguments ([] );
273
261
}
274
262
}
275
263
0 commit comments