php - How to change a Symfony parameter

60

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?

882

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

People are also looking for solutions to the problem: php - Display Count of Collected and Released Blood Components

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.