2323use Symfony \Component \Routing \Generator \ConfigurableRequirementsInterface ;
2424use Symfony \Component \Routing \Generator \Dumper \CompiledUrlGeneratorDumper ;
2525use Symfony \Component \Routing \Generator \Dumper \GeneratorDumperInterface ;
26+ use Symfony \Component \Routing \Generator \Dumper \PhpGeneratorDumper ;
2627use Symfony \Component \Routing \Generator \UrlGenerator ;
2728use Symfony \Component \Routing \Generator \UrlGeneratorInterface ;
2829use Symfony \Component \Routing \Matcher \CompiledUrlMatcher ;
2930use Symfony \Component \Routing \Matcher \Dumper \CompiledUrlMatcherDumper ;
3031use Symfony \Component \Routing \Matcher \Dumper \MatcherDumperInterface ;
32+ use Symfony \Component \Routing \Matcher \Dumper \PhpMatcherDumper ;
3133use Symfony \Component \Routing\Matcher \RequestMatcherInterface ;
3234use Symfony \Component \Routing \Matcher \UrlMatcher ;
3335use Symfony \Component \Routing \Matcher \UrlMatcherInterface ;
@@ -394,6 +396,11 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac
394396 */
395397 protected function getGeneratorDumperInstance ()
396398 {
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+
397404 return new $ this ->options ['generator_dumper_class ' ]($ this ->getRouteCollection ());
398405 }
399406
@@ -402,6 +409,11 @@ protected function getGeneratorDumperInstance()
402409 */
403410 protected function getMatcherDumperInstance ()
404411 {
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+
405417 return new $ this ->options ['matcher_dumper_class ' ]($ this ->getRouteCollection ());
406418 }
407419
0 commit comments