-- Rob Allen <[EMAIL PROTECTED]> wrote
(on Wednesday, 09 May 2007, 03:22 PM +0100):
> Matthew Weier O'Phinney wrote:
> > -- Rob Allen <[EMAIL PROTECTED]> wrote
> > (on Tuesday, 08 May 2007, 07:01 AM +0100):
> > > Todd Wolaver wrote:
> > > > Yes, I've just run into this myself and I ended up using
> > > > the Zend_Controller_Front::getInstance()
> > > >
> > > > i.e.
> > > > $this->_config  = 
> > > > Zend_Controller_Front::getInstance()->getParam('config');
> > > >
> > > > Todd
> > > >
> > > Isn't this just like treating the front controller as if it's a
> > > registry? If so, I would have thought that using Zend_Registry would
> > > make it more explicit that this is what you are doing?
> > >
> > > i.e. what's the benefit of using the FC's setParam() in these cases over
> > > Zend_Registry?
> > 
> > The idea of adding parameter handling to the front controller arose out
> > of a desire to reduce the number of dependencies in the front controller
> > (loose coupling), as well as allow the ability to pass *any* type of
> > variable through the front controller chain. Zend_Registry is an
> > object-only registry, so it fails in the second case, and introduces a
> > dependency in the first.,
> 
> I'm nearly sure Zend_Registry is no longer object-only.

Oh, interesting! I get so wrapped up in components I work on, I often don't
look under the hood at others. I see that Zend_Registry now extends
ArrayObject, and that set() no longer checks that the $value passed is
an object... so, I stand corrected.

<snip>

> > As to the benefit of using the front controller params instead of a
> > registry, it helps keep such objects in a specific domain. Were these
> > registered in a general global registry, it wouldn't be clear that they
> > are meant for use with the MVC components specifically. It's really a
> > matter of preference, but that's certainly one argument I've used.
> 
> Yeah - definitely a toss-up; especially for params that aren't used
> until you get to the action function itself. I just wanted to ensure
> that I wasn't missing a clearly better way of doing it :)
> 
> Personally, I wouldn't pass config or the database adapter around as a
> front controller param, but that's just me!

It's basically a matter of preference. Do you need a global registry in
your application, or are you simply doing an MVC app? If your code isn't
going to be re-used in cronjobs, services, or other arenas, pushing the
database connection and config objects into the front controller (and
hence the router, dispatcher, and action controllers) might make as much
sense as using a registry, and save you the effort of loading and
calling on the registry within your code. If you *will* be re-using such
objects in other types of scripts, though, then passing them into the
registry probably makes more sense.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to