Reputation: 3006
I have a bootstrap class which I want to use to set CSS variables:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initView()
{
$this->bootstrap('view');
...
...
}
}
But trying to get the view resource fails at the bootstrap('view')
stage. I get the error:
... Circular resource dependency detected' in C:\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php on line 662
...
Which is strange because this is the procedure that tutorials(and the zend documentation) use. What could be wrong?
Upvotes: 2
Views: 1555
Reputation: 14184
Change the method to something like _initViewStuff()
and all will be fine.
The reason is that the bootstrap sequence in Zend_Application_Bootstrap_BootstrapAbstract
is as follows:
Your initial call to $app->bootstrap()
in public/index.php
runs through all _initXxx()
methods (@see Zend_Application_Bootstrap_BootstrapAbstract::getClassResourceNames()
) and calls $this->bootstrap('xxx')
for each Xxx
it finds. It will then do a similar thing for all the plugin resources defined by resources.*
keys in application.ini
(though yours never gets that far, as described below).
The call to bootstrap('view')
internally stores a flag that he has started the process to bootstrap a resource called view
.
He does a similar thing as (1), looking for a matching _initXxx()
method. He find it and attempts to execute $this->_initView()
He notices the flag he set, indicating that he's gonna hit an infinite loop, so he bails out with circular dependency exception.
Typically, for each resource xxx
, you bootstrap it using one (but not both, as you have discovered) of the following approaches:
Define an _initXxx()
method.
Creating a plugin resource class named something like My_Application_Resource_Xxx
(you inform that system that My_Application_Resource_
is a namespace prefix for plugin resources using pluginPaths.My_Application_Resource = /path/to/dir/containing/plugin
in application/configs/application.ini
)
Upvotes: 3
Reputation: 8840
You cant use this method name in your bootstrap class '_initView' because there is corresponding Zend_Application_Resource_View
, just rename your bootstrap method name
Upvotes: 2