-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[FrameworkBundle] Add EnabledLocalesPass to process environment varia… #62108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 8.1
Are you sure you want to change the base?
Conversation
17228a8 to
7e697a7
Compare
…bles for enabled locales
7e697a7 to
8fe1a87
Compare
|
@GromNaN take a look, please. |
|
Resolving env placeholders in a compiler pass and replacing the parameter value is not a way to make env placeholders supported, as it does not respect the expected semantic. You will now need to clear your cache so that the new value of the env variable is taken into account. So -1 for this PR. |
|
but currently is the same situation, if in config provided a list of enabledLocales, after adding a new one you should rebuild cache |
|
@stof if I use configuration like env(json:AVAILABLE_LOCALES) and try to use $container->resolveEnvPlaceholders($enabledLocales, true) i get an error Do you have an alternative proposition for solving this situation? |
GromNaN
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without major changes to the router, it isn't possible to accept an environment variable in the routes configuration.
Sorry for giving you the wrong direction, I hadn't thought of everything.
| } | ||
|
|
||
| private function registerTranslatorConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader, string $defaultLocale, array $enabledLocales): void | ||
| private function registerTranslatorConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader, string $defaultLocale): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the translator, there is only this type to modify to accept a parameter. The default.translator service car receive an %env(...)% value that is resolved by the DIC at runtime.
| private function registerTranslatorConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader, string $defaultLocale): void | |
| private function registerTranslatorConfiguration(array $config, ContainerBuilder $container, LoaderInterface $loader, string $defaultLocale, array|string $enabledLocales): void |
But it needs a bit of refactoring to merge the lists from enabled locales and providers at runtime in the commands.
| } | ||
|
|
||
| private function registerRouterConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader, array $enabledLocales = []): void | ||
| private function registerRouterConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accepting environment variables in the router isn't possible. The values are dumped in the routing cache, in a big regex for the url matcher.
The expression language is the only way we have currently to match parts of the request with env var.
…bles for enabled locales
This pull request is a result of discussion #61745
It gives a possibility to set enabledLocales via env variable.