Closed alekitto closed 3 years ago
thanks for the detailed report. i had a look, and this indeed does not make too much sense. the validator that is called "RouteDefaultsTwigValidator" also validates the route parameters with a router and thus is not only about twig.
glad if you can do a pull request to have the twig argument nullable and have the service definition for the validator say on-invalid="null"
. also, lets move twig to the dev-dependencies. no point in forcing you to have twig installed if we don't need it.
fixed in #461 and released as https://github.com/symfony-cmf/routing-bundle/releases/tag/2.5.0
thanks for bringing it up and adjusting it, @alekitto !
I'm using this bundle to leverage dynamic routing capabilities on an API-based project. Twig is obviously not installed in production (in dev is a requirement of Symfony web-profiler.
When building the container image for production, the build breaks with this error:
This is due to the
RouteDefaultsTwigValidator
class requiring a non-optionalTwig\Loader\LoaderInterface
as second argument. Unfortunately, this validator cannot be disabled by configuration, so I had to overwrite it with a custom version that not requires the twig loader.One possible fix is to accept also
null
as$twig
argument and skip the template check if the loader is not present.Environment
PHP 8.0.3