-- Ehask71 <[email protected]> wrote
(on Monday, 08 June 2009, 07:03 AM -0700):
> Thx!  But now I get errors "No Registry Entry for logger"  I guess its back
> to the Docs to figure out how setting Registry stuff was changed.  

The bootstrap uses what is considered a "local" registry, versus a
global static registry. As a result, you cannot use Zend_Registry's get,
set, or isRegistered methods in order to locate items, as these operate
on the global, static registry.

As a convenience, the bootstrap exposes a "getResource()" method which
can be used to pull resources from the local registry by name. 

The bootstrap gets registered with the front controller as a parameter,
so you can always fetch a resource by pulling the bootstrap from the
front controller. For example, to get your "logger" resource, try the
following:

    $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
    $logger    = $bootstrap->getResource('logger');

    // or, using method chaining:
    $logger = Zend_Controller_Front::getInstance()
            ->getParam('bootstrap')
            ->getResource('logger');

Within your action controllers, front controller parameters may be
pulled using the getInvokeArg() method; you can use this to get your
bootstrap... and then your resource:

    $bootstrap = $this->getInvokeArg('bootstrap');
    $logger    = $bootstrap->getResource('logger');

    // or, using method chaining:
    $logger = $this->getInvokeArg('bootstrap')
            ->getResource('logger');
    
This is documented in the manual; see section 4.3.1.3, "Resource
Registry", here:

    
http://framework.zend.com/manual/en/zend.application.theory-of-operation.html#zend.application.theory-of-operation.bootstrap.registry

> Man this can kill dev time especially when you quote x Hours on a
> project then ZF jacks everything up from the way you thought it or
> used to work. 

We've been trying hard to build out functionality incrementally. The
addition of Zend_Application codifies some paradigms and best practices
we've been working on, but it's clear that migration has been a bit
difficult for some. If you have any thoughts on how to mitigate this in
the future, I'd love to hear them!

> There are no good examples out to show what a new Bootstrap should look like
> compared to an old one with Modules,Logger, etc.  The Reference and Wiki
> always leave me scratching my head LOL

Well, we didn't actually have a formal bootstrap class previously, so
I'm not entirely sure what you're referring to. Previously,
bootstrapping was entirely procedural.


> Jurian Sluiman wrote:
> > You could create a Db resource which will initiate your database and
> > set the adapter to the default one. You also create a log resource,
> > which first bootstraps the db resource. Then you're sure the db is
> > setup correctly.  The $db var is the same as
> > Zend_Db_Table::getDefaultAdapter() :)

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/

Reply via email to