>
> Actually I was using the approach you mentioned above, until I realized
> that it requires more memory, since an entire instance of Zend_Config is
> stored into Zend_Registry. So I decided to store only config's _DATA_
> into Zend_Registry to save the mem.
>

Are you writing code for the Atari 800?  ;-)
The solution Matthew posted is much more readable and easier to debug for
other developers who may take over your project later.
-Matt

On Thu, Jul 10, 2008 at 6:24 AM, AmirBehzad Eslami <[EMAIL PROTECTED]>
wrote:

> >> why don't you just store the config object in the registry, and
> >> then pull values from there...?
>
> Actually I was using the approach you mentioned above,
> until I realized that it requires more memory, since an entire
> instance of Zend_Config is stored into Zend_Registry.
> So I decided to store only config's _DATA_ into
> Zend_Registry to save the mem.
>
> By the way, I found a way to store config's key-value pairs at once
> into Zend_Registry (thanks to the Zend_Registy for extending
> ArrayObject).
>
> Zend_Registry::setInstance(
>     new Zend_Registry($config->toArray()));
> unset($config);
>
> > This is a much better solution [storing the config object in the
> registry],
> > as then you don't need to worry about
> checking to see if various
> > registry keys are set.
> I don't see how. Even I have a config object, I can't be 100%-certain about
> existence of its key/value pairs. Perhaps the config file lacks a key.
> Would you please explain a little more. Maybe I'm missing something.
>
> Thanks you,
> AmirBehzad
>
>
>
> On Thu, Jul 10, 2008 at 4:20 PM, Matthew Weier O'Phinney <[EMAIL PROTECTED]>
> wrote:
>
>> -- AmirBehzad Eslami <[EMAIL PROTECTED]> wrote
>> (on Thursday, 10 July 2008, 02:03 PM +0330):
>> > Hi list,
>> > I'm trying to store values from a Zend_Config object into Zend_Registry.
>> >
>> > $config = new Zend_Config_Xml(APP_DIR . '/config.xml', $curr_env);
>> > foreach ($config as $key => $value) {
>> >     Zend_Registry::set($key, $value);
>> > }
>> >
>> > As you see, I'm iterating over $config object to store the values into
>> the
>> > registry.
>> > Is there any plan to implement a special method (perhaps setFromArray())
>> to
>> > facilitate this action? Is there any other way to store multiple values
>> into
>> > the
>> > registry at once, with a single line of code?
>>
>> Umm... why don't you just store the config object in the registry, and
>> then pull values from there...?
>>
>>    // setting...
>>    Zend_Registry::set('config', $config);
>>
>>    // retrieving...
>>    $env = Zend_Registry::get('config')->env;
>>
>> This is a much better solution, as then you don't need to worry about
>> checking to see if various registry keys are set.
>>
>> --
>> Matthew Weier O'Phinney
>> Software Architect       | [EMAIL PROTECTED]
>> Zend Framework           | http://framework.zend.com/
>>
>
>
>
> --
> Kind regards,
> -behzad

Reply via email to