I’m new using symfony, and I can’t seem to find a proper solution to my problem.
The thing is, I have a backend module with all the configuration for the website (sitename, items per page, default style). I want to configure the generator.yml file so in the list field I can set the value of max_per_page not as a static number but fetched from the database.
I know I could use php code in that file but since it’s cached I don’t think that’d be the best solution. My generator.yml file looks like this:
generator:
class: sfDoctrineGenerator
param:
model_class: PodcastUsers
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: podcast_users
with_doctrine_route: true
actions_base_class: sfActions
config:
actions: ~
fields: ~
list:
max_per_page: 10;
filter: ~
form: ~
edit: ~
new: ~
Is there any way to initialize the max_per_page value from the code somewhere so if I change that number in the db it’d be instantly refreshed?
Thanks in advance!
Fortunately .yml files can be parsed as PHP so you can insert PHP code. No idea how you are going to store this max_per_page value, but you can create or edit an existing model file and add a method to retrieve the value, then include it in your yaml file. Following is demonstrative only: