apprentice (77) [Avatar] Offline
#1
How do you store $config object to the Zend_Registry, the 1.8 way?

My code is entirely based on the 1.8 Akrabat tutorial so the MVC startup files looks identical. I'm really weak at reading and following what the MVC files do and...
http://akrabat.com/zend-framework-tutorial/

...I'm trying to compare how ZFiA Places application sets the $config object to Registry. But I don't know how to imitate that part of the code for Akrabat's Album application.

The initialization of the config file looks so different between Places app and Albums app. I don't know how to deal with this correctly the 1.8 way, help anybody?
jnunez (18) [Avatar] Offline
#2
Re: [1.8] - How do you store $config object to the Zend_Registry?
The easiest way that I know is to add the same code that you are using in the bootstrap of the Places app to a method in your 1.8 bootstrap.

public function _initConfiguration()
{
// enter your Zend Registry code here...
}

There are ways to get resources from the bootstrap but I haven't seen a method to get the config. Maybe you can trace the code from the Zend_Application's __construct() to see what it does with the config data.
akrabat (479) [Avatar] Offline
#3
Re: [1.8] - How do you store $config object to the Zend_Registry?
[pre]
protected function _initConfig()
{
$config = new Zend_Config($this->getOptions());
Zend_Registry::set('config', $config);
return $config;
}
[/pre]

Regards,

Rob...
apprentice (77) [Avatar] Offline
#4
Re: [1.8] - How do you store $config object to the Zend_Registry?
Thanks Rob! This should allow me to connect $config to $db, Zend_Log and Zend_Db_Profiler. smilie