I am working on a plugin which adds stylesheets to the response based
on configuration from the database. In my first attempt, I tried
calling '$response->addStylesheet(...)' in my
PluginConfiguration::initialize() method, but got this error:

sfException: The "default" context does not exist. in /home/jablko/
public_html/foo/lib/vendor/symfony/lib/util/sfContext.class.php on
line 110
Call Stack
#       Time    Memory  Function        Location
1       0.0004  64548   {main}( )       ../foo_dev.php:0
2       0.0057  300552  sfProjectConfiguration::getApplicationConfiguration
( )     ../foo_dev.php:12
3       0.0090  485168  sfApplicationConfiguration->__construct( )      ../
sfProjectConfiguration.class.php:571
4       0.0226  805556  sfApplicationConfiguration->initConfiguration( )        
../
sfApplicationConfiguration.class.php:50
5       0.0343  1309692 sfApplicationConfiguration->initializePlugins( )        
../
sfApplicationConfiguration.class.php:144
6       0.0463  1969968 fooPluginConfiguration->initialize( )   ../
sfApplicationConfiguration.class.php:171
7       0.0474  2060108 sfContext::getInstance( )       ../
fooPluginConfiguration.class.php:28

I got a similar error trying to access the database in my
PluginConfiguration::initialize() method.

So I guess PluginConfiguration::initialize() is called before the
context or database connection exist. What is the correct approach to
adding stylesheets to the response, based on configuration from the
database?

This is roughly what my PluginConfiguration::initialize() looks like:

    $property = PropertyPeer::retrieveByPk('stylesheet');

    $response = sfContext::getInstance()->getResponse();
    $response->addStylesheet($property->getValue());
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" 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-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to