This is not the correct way to handle this.
Yaml configuration files are meant for static values. If you need
something dynamic, this is probably the wrong way to achieve it.

In my opinion, a better approach would be to create a filter in the
filter chain, righe before the cache filter, that retrieves the
settings from the database and adds them in the sfConfig registry.
Something like:

class SettingsFilter extends sfFilter
{
  public function execute(sfFilterChain $filterChain)
  {
    foreach (SettingPeer::getIndex() as $setting)
    {
      sfConfig::set('app_' . $setting->getSlug(), $setting-
>getValue());
    }
    $filterChain->execute();
  }
}

and in the filters.yml

rendering: ~
security:  ~
# insert your own filters here
settings: { class: SettingsFilter }
cache:     ~
execution: ~


This will keep configuration files clean, and still have the
possibility to change the values from a backend, without having
dynamic Yaml files.
Also remember that yml files are parsed only once, then they're all
cached. So even changing the value in the database, Symfony would use
the old data resulting of the last time app.yml was parsed.

Keep also in mind that whatever way you do, this will add the overhead
of a query for each request. A good choice would be to use a cache
(APC would be a good choice) that is refreshed each time the settings
are updated.

I hope this helps :)

On Jul 1, 2:51 pm, HAUSa <[email protected]>
wrote:
> I want to use some configuration settings from the database in my
> app.yml configuration file.
> This is my code now:
>
> all:
> <?php foreach(SettingPeer::getIndex() as $oSetting): ?>
>   <?php echo $oSetting->getSlug() . ': ' . $oSetting->getValue() ?>
> <?php endforeach; ?>
>
> But the error I receive says "No connection information in your
> runtime configuration file for datasource [propel]"
>
> What should I do to make this happen?
> Thanks!

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to