php - How to change a Symfony parameter
I'm using LiipThemeBundle which supports different themes on the website, depending on a parameter (liip_theme.active_theme):
liip_theme:
themes: ['standardTheme', 'blackTheme']
active_theme: 'standardTheme'
I wanted to change the active theme from a form or take it from the database, to allow dynamic theme changing. The problem is that the parameter is being cached, and you can't change parameter values without deleting the cache. I also believe deleting the whole cache just for a parameter is not a good idea.
So modifying the yml value with a value from the database won't work on the prod environment (because it takes it from the cache). This seems like the best solution, if I can find a way to 'inject' it in the cache.
A compiler pass is not a good idea either, as the parameter is being changed sometimes, only when the admin of the website decides to change it.
How to change a parameter or not allow it to be cached?
Answer
Solution:
Well, you should try:
liip_theme: themes: ['standardTheme', 'blackTheme'] active_theme: "%liip_theme%"
within %liip_theme% defined in parameters section of config.ml