One more quick question, is it possible to 'easily' access what you
set in setParam in the bootstrap in a plugin without using the
registry?
- Robert
On Thu, Apr 10, 2008 at 3:33 PM, Robert Castley
<[EMAIL PROTECTED]> wrote:
> Brilliant! Thank you!
>
> - Robert
>
>
>
> On 10 Apr 2008, at 15:11, Matthew Weier O'Phinney wrote:
>
>
> > -- Robert Castley <[EMAIL PROTECTED]> wrote
> > (on Thursday, 10 April 2008, 02:50 PM +0100):
> >
> > > What are the main differences between the following code examples and
> which is
> > > the best method and which would be quicker?
> > >
> > > They both seem to achieve the end goal!
> > >
> > >
> > >
> > > OPTION 1
> > > --------
> > > Index.php (Bootstrap)
> > >
> > > <?php
> > > Zend_Registry::set('config', new Zend_Config_Ini('magik.ini'));
> > > ?>
> > >
> > > IndexController.php
> > >
> > > <?php
> > > $this->view->timeZone = Zend_Registry::get('config')->general->timeZone;
> > > ?>
> > >
> > >
> > >
> > > OPTION 2
> > > --------
> > > Index.php (Bootstrap)
> > >
> > > <?php
> > > $config = new Zend_Config_Ini('magik.ini');
> > > ...
> > > $controller = Zend_Controller_Front::getInstance();
> > > $controller->setParam('config', $config);
> > > ?>
> > >
> > > IndexController.php
> > >
> > > <?php
> > > $this->view->timeZone =
> $this->getFrontController()->getParam('config')->
> > > general->timeZone);
> > >
> >
> > Actually, this last can be shortened, as front controller params are
> > pushed into the action controllers as "invokeArgs":
> >
> > $this->view->timeZone =
> $this->getInvokeArg('config')->general->timeZone;
> >
> > In truth, both the registry and front controller are singletons, and
> > it's really a matter of preference which one you use. The reason that
> > the front controller parameters exist was two-fold: to allow messaging
> > to the various sub-components in Zend_Controller (router, dispatcher,
> > etc), and to obviate the use of the Registry for those who didn't want
> > to load an additional component.
> >
> > If you might be using your config in places *other* than the MVC
> > components, using the Registry would make more sense. If all you're
> > throwing in there is stuff your MVC components need, use the front
> > controller params.
> >
> > --
> > Matthew Weier O'Phinney
> > Software Architect | [EMAIL PROTECTED]
> > Zend - The PHP Company | http://www.zend.com/
> >
>
>
--
- Robert