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 ;
@@ -388,6 +390,11 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac
388390 */
389391 protected function getGeneratorDumperInstance ()
390392 {
393+ // For BC, fallback to PhpGeneratorDumper if the UrlGenerator and UrlGeneratorDumper are not consistent with each other
394+ if (is_a ($ this ->options ['generator_class ' ], CompiledUrlGenerator::class, true ) !== is_a ($ this ->options ['generator_dumper_class ' ], CompiledUrlGeneratorDumper::class, true )) {
395+ return new PhpGeneratorDumper ($ this ->getRouteCollection ());
396+ }
397+
391398 return new $ this ->options ['generator_dumper_class ' ]($ this ->getRouteCollection ());
392399 }
393400
@@ -396,6 +403,11 @@ protected function getGeneratorDumperInstance()
396403 */
397404 protected function getMatcherDumperInstance ()
398405 {
406+ // For BC, fallback to PhpMatcherDumper if the UrlMatcher and UrlMatcherDumper are not consistent with each other
407+ if (is_a ($ this ->options ['matcher_class ' ], CompiledUrlMatcher::class, true ) !== is_a ($ this ->options ['matcher_dumper_class ' ], CompiledUrlMatcherDumper::class, true )) {
408+ return new PhpMatcherDumper ($ this ->getRouteCollection ());
409+ }
410+
399411 return new $ this ->options ['matcher_dumper_class ' ]($ this ->getRouteCollection ());
400412 }
401413
0 commit comments