23
23
use Symfony \Component \Routing \Generator \ConfigurableRequirementsInterface ;
24
24
use Symfony \Component \Routing \Generator \Dumper \CompiledUrlGeneratorDumper ;
25
25
use Symfony \Component \Routing \Generator \Dumper \GeneratorDumperInterface ;
26
+ use Symfony \Component \Routing \Generator \Dumper \PhpGeneratorDumper ;
26
27
use Symfony \Component \Routing \Generator \UrlGenerator ;
27
28
use Symfony \Component \Routing \Generator \UrlGeneratorInterface ;
28
29
use Symfony \Component \Routing \Matcher \CompiledUrlMatcher ;
29
30
use Symfony \Component \Routing \Matcher \Dumper \CompiledUrlMatcherDumper ;
30
31
use Symfony \Component \Routing \Matcher \Dumper \MatcherDumperInterface ;
32
+ use Symfony \Component \Routing \Matcher \Dumper \PhpMatcherDumper ;
31
33
use Symfony \Component \Routing \Matcher \RequestMatcherInterface ;
32
34
use Symfony \Component \Routing \Matcher \UrlMatcher ;
33
35
use Symfony \Component \Routing \Matcher \UrlMatcherInterface ;
@@ -394,6 +396,11 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac
394
396
*/
395
397
protected function getGeneratorDumperInstance ()
396
398
{
399
+ // For BC, fallback to PhpGeneratorDumper if the UrlGenerator and UrlGeneratorDumper are not consistent with each other
400
+ if (is_a ($ this ->options ['generator_class ' ], CompiledUrlGenerator::class, true ) !== is_a ($ this ->options ['generator_dumper_class ' ], CompiledUrlGeneratorDumper::class, true )) {
401
+ return new PhpGeneratorDumper ($ this ->getRouteCollection ());
402
+ }
403
+
397
404
return new $ this ->options ['generator_dumper_class ' ]($ this ->getRouteCollection ());
398
405
}
399
406
@@ -402,6 +409,11 @@ protected function getGeneratorDumperInstance()
402
409
*/
403
410
protected function getMatcherDumperInstance ()
404
411
{
412
+ // For BC, fallback to PhpMatcherDumper if the UrlMatcher and UrlMatcherDumper are not consistent with each other
413
+ if (is_a ($ this ->options ['matcher_class ' ], CompiledUrlMatcher::class, true ) !== is_a ($ this ->options ['matcher_dumper_class ' ], CompiledUrlMatcherDumper::class, true )) {
414
+ return new PhpMatcherDumper ($ this ->getRouteCollection ());
415
+ }
416
+
405
417
return new $ this ->options ['matcher_dumper_class ' ]($ this ->getRouteCollection ());
406
418
}
407
419
0 commit comments