@@ -113,13 +113,9 @@ public function __construct(LoaderInterface $loader, $resource, array $options =
113113 * * cache_dir: The cache directory (or null to disable caching)
114114 * * debug: Whether to enable debugging or not (false by default)
115115 * * 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
118116 * * generator_dumper_class: The name of a GeneratorDumperInterface implementation
119117 * * 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
123119 * * resource_type: Type hint for the main resource (optional)
124120 * * strict_requirements: Configure strict requirement checking for generators
125121 * implementing ConfigurableRequirementsInterface (default is true)
@@ -134,20 +130,21 @@ public function setOptions(array $options)
134130 'cache_dir ' => null ,
135131 'debug ' => false ,
136132 'generator_class ' => CompiledUrlGenerator::class,
137- 'generator_base_class ' => UrlGenerator::class,
133+ 'generator_base_class ' => UrlGenerator::class, // deprecated
138134 'generator_dumper_class ' => CompiledUrlGeneratorDumper::class,
139- 'generator_cache_class ' => 'UrlGenerator ' ,
135+ 'generator_cache_class ' => 'UrlGenerator ' , // deprecated
140136 'matcher_class ' => CompiledUrlMatcher::class,
141- 'matcher_base_class ' => UrlMatcher::class,
137+ 'matcher_base_class ' => UrlMatcher::class, // deprecated
142138 'matcher_dumper_class ' => CompiledUrlMatcherDumper::class,
143- 'matcher_cache_class ' => 'UrlMatcher ' ,
139+ 'matcher_cache_class ' => 'UrlMatcher ' , // deprecated
144140 'resource_type ' => null ,
145141 'strict_requirements ' => true ,
146142 ];
147143
148144 // check option names and live merge, if errors are encountered Exception will be thrown
149145 $ invalid = [];
150146 foreach ($ options as $ key => $ value ) {
147+ $ this ->checkDeprecatedOption ($ key );
151148 if (array_key_exists ($ key , $ this ->options )) {
152149 $ this ->options [$ key ] = $ value ;
153150 } else {
@@ -174,6 +171,8 @@ public function setOption($key, $value)
174171 throw new \InvalidArgumentException (sprintf ('The Router does not support the "%s" option. ' , $ key ));
175172 }
176173
174+ $ this ->checkDeprecatedOption ($ key );
175+
177176 $ this ->options [$ key ] = $ value ;
178177 }
179178
@@ -192,6 +191,8 @@ public function getOption($key)
192191 throw new \InvalidArgumentException (sprintf ('The Router does not support the "%s" option. ' , $ key ));
193192 }
194193
194+ $ this ->checkDeprecatedOption ($ key );
195+
195196 return $ this ->options [$ key ];
196197 }
197198
@@ -279,7 +280,7 @@ public function getMatcher()
279280 return $ this ->matcher ;
280281 }
281282
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 ' ] ;
283284
284285 if (null === $ this ->options ['cache_dir ' ] || null === $ this ->options ['matcher_cache_class ' ]) {
285286 $ routes = $ this ->getRouteCollection ();
@@ -336,7 +337,7 @@ public function getGenerator()
336337 return $ this ->generator ;
337338 }
338339
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 ' ] ;
340341
341342 if (null === $ this ->options ['cache_dir ' ] || null === $ this ->options ['generator_cache_class ' ]) {
342343 $ routes = $ this ->getRouteCollection ();
@@ -411,4 +412,15 @@ private function getConfigCacheFactory()
411412
412413 return $ this ->configCacheFactory ;
413414 }
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+ }
414426}
0 commit comments