@@ -113,13 +113,9 @@ public function __construct(LoaderInterface $loader, $resource, array $options =
113
113
* * cache_dir: The cache directory (or null to disable caching)
114
114
* * debug: Whether to enable debugging or not (false by default)
115
115
* * generator_class: The name of a UrlGeneratorInterface implementation
116
- * * generator_base_class: The base class for the dumped generator class
117
- * * generator_cache_class: The class name for the dumped generator class
118
116
* * generator_dumper_class: The name of a GeneratorDumperInterface implementation
119
117
* * matcher_class: The name of a UrlMatcherInterface implementation
120
- * * matcher_base_class: The base class for the dumped matcher class
121
- * * matcher_dumper_class: The class name for the dumped matcher class
122
- * * matcher_cache_class: The name of a MatcherDumperInterface implementation
118
+ * * matcher_dumper_class: The name of a MatcherDumperInterface implementation
123
119
* * resource_type: Type hint for the main resource (optional)
124
120
* * strict_requirements: Configure strict requirement checking for generators
125
121
* implementing ConfigurableRequirementsInterface (default is true)
@@ -134,20 +130,21 @@ public function setOptions(array $options)
134
130
'cache_dir ' => null ,
135
131
'debug ' => false ,
136
132
'generator_class ' => CompiledUrlGenerator::class,
137
- 'generator_base_class ' => UrlGenerator::class,
133
+ 'generator_base_class ' => UrlGenerator::class, // deprecated
138
134
'generator_dumper_class ' => CompiledUrlGeneratorDumper::class,
139
- 'generator_cache_class ' => 'UrlGenerator ' ,
135
+ 'generator_cache_class ' => 'UrlGenerator ' , // deprecated
140
136
'matcher_class ' => CompiledUrlMatcher::class,
141
- 'matcher_base_class ' => UrlMatcher::class,
137
+ 'matcher_base_class ' => UrlMatcher::class, // deprecated
142
138
'matcher_dumper_class ' => CompiledUrlMatcherDumper::class,
143
- 'matcher_cache_class ' => 'UrlMatcher ' ,
139
+ 'matcher_cache_class ' => 'UrlMatcher ' , // deprecated
144
140
'resource_type ' => null ,
145
141
'strict_requirements ' => true ,
146
142
];
147
143
148
144
// check option names and live merge, if errors are encountered Exception will be thrown
149
145
$ invalid = [];
150
146
foreach ($ options as $ key => $ value ) {
147
+ $ this ->checkDeprecatedOption ($ key );
151
148
if (array_key_exists ($ key , $ this ->options )) {
152
149
$ this ->options [$ key ] = $ value ;
153
150
} else {
@@ -160,6 +157,8 @@ public function setOptions(array $options)
160
157
}
161
158
}
162
159
160
+
161
+
163
162
/**
164
163
* Sets an option.
165
164
*
@@ -174,6 +173,8 @@ public function setOption($key, $value)
174
173
throw new \InvalidArgumentException (sprintf ('The Router does not support the "%s" option. ' , $ key ));
175
174
}
176
175
176
+ $ this ->checkDeprecatedOption ($ key );
177
+
177
178
$ this ->options [$ key ] = $ value ;
178
179
}
179
180
@@ -192,6 +193,8 @@ public function getOption($key)
192
193
throw new \InvalidArgumentException (sprintf ('The Router does not support the "%s" option. ' , $ key ));
193
194
}
194
195
196
+ $ this ->checkDeprecatedOption ($ key );
197
+
195
198
return $ this ->options [$ key ];
196
199
}
197
200
@@ -279,7 +282,7 @@ public function getMatcher()
279
282
return $ this ->matcher ;
280
283
}
281
284
282
- $ compiled = is_a ($ this ->options ['matcher_class ' ], CompiledUrlMatcher::class, true );
285
+ $ compiled = is_a ($ this ->options ['matcher_class ' ], CompiledUrlMatcher::class, true ) && UrlMatcher::class === $ this -> options [ ' matcher_base_class ' ] ;
283
286
284
287
if (null === $ this ->options ['cache_dir ' ] || null === $ this ->options ['matcher_cache_class ' ]) {
285
288
$ routes = $ this ->getRouteCollection ();
@@ -336,7 +339,7 @@ public function getGenerator()
336
339
return $ this ->generator ;
337
340
}
338
341
339
- $ compiled = is_a ($ this ->options ['generator_class ' ], CompiledUrlGenerator::class, true );
342
+ $ compiled = is_a ($ this ->options ['generator_class ' ], CompiledUrlGenerator::class, true ) && UrlGenerator::class === $ this -> options [ ' generator_base_class ' ] ;
340
343
341
344
if (null === $ this ->options ['cache_dir ' ] || null === $ this ->options ['generator_cache_class ' ]) {
342
345
$ routes = $ this ->getRouteCollection ();
@@ -411,4 +414,15 @@ private function getConfigCacheFactory()
411
414
412
415
return $ this ->configCacheFactory ;
413
416
}
417
+
418
+ private function checkDeprecatedOption ($ key )
419
+ {
420
+ switch ($ key ) {
421
+ case 'generator_base_class ' :
422
+ case 'generator_cache_class ' :
423
+ case 'matcher_base_class ' :
424
+ case 'matcher_cache_class ' :
425
+ @trigger_error (sprintf ('Option "%s" given to router %s is deprecated since Symfony 4.2. ' , $ key , static ::class), E_USER_DEPRECATED );
426
+ }
427
+ }
414
428
}
0 commit comments