@@ -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 {
@@ -174,6 +171,8 @@ public function setOption($key, $value)
174
171
throw new \InvalidArgumentException (sprintf ('The Router does not support the "%s" option. ' , $ key ));
175
172
}
176
173
174
+ $ this ->checkDeprecatedOption ($ key );
175
+
177
176
$ this ->options [$ key ] = $ value ;
178
177
}
179
178
@@ -192,6 +191,8 @@ public function getOption($key)
192
191
throw new \InvalidArgumentException (sprintf ('The Router does not support the "%s" option. ' , $ key ));
193
192
}
194
193
194
+ $ this ->checkDeprecatedOption ($ key );
195
+
195
196
return $ this ->options [$ key ];
196
197
}
197
198
@@ -279,7 +280,7 @@ public function getMatcher()
279
280
return $ this ->matcher ;
280
281
}
281
282
282
- $ compiled = is_a ($ this ->options ['matcher_class ' ], CompiledUrlMatcher::class, true );
283
+ $ compiled = is_a ($ this ->options ['matcher_class ' ], CompiledUrlMatcher::class, true ) && UrlMatcher::class === $ this -> options [ ' matcher_base_class ' ] ;
283
284
284
285
if (null === $ this ->options ['cache_dir ' ] || null === $ this ->options ['matcher_cache_class ' ]) {
285
286
$ routes = $ this ->getRouteCollection ();
@@ -336,7 +337,7 @@ public function getGenerator()
336
337
return $ this ->generator ;
337
338
}
338
339
339
- $ compiled = is_a ($ this ->options ['generator_class ' ], CompiledUrlGenerator::class, true );
340
+ $ compiled = is_a ($ this ->options ['generator_class ' ], CompiledUrlGenerator::class, true ) && UrlGenerator::class === $ this -> options [ ' generator_base_class ' ] ;
340
341
341
342
if (null === $ this ->options ['cache_dir ' ] || null === $ this ->options ['generator_cache_class ' ]) {
342
343
$ routes = $ this ->getRouteCollection ();
@@ -411,4 +412,15 @@ private function getConfigCacheFactory()
411
412
412
413
return $ this ->configCacheFactory ;
413
414
}
415
+
416
+ private function checkDeprecatedOption ($ key )
417
+ {
418
+ switch ($ key ) {
419
+ case 'generator_base_class ' :
420
+ case 'generator_cache_class ' :
421
+ case 'matcher_base_class ' :
422
+ case 'matcher_cache_class ' :
423
+ @trigger_error (sprintf ('Option "%s" given to router %s is deprecated since Symfony 4.3. ' , $ key , static ::class), E_USER_DEPRECATED );
424
+ }
425
+ }
414
426
}
0 commit comments