(on Wednesday, 15 April 2009, 08:30 AM +0100):
> On 13 Apr 2009, at 15:50, Matthew Weier O'Phinney wrote:
> > The idea here would be that if a resource method or plugin has a
> > non-null return value, then that value would be registered with the
> > registry.
>
> I really like this idea.
>
> > Because the resource now has an explicit return value, the Bootstrap
> > would register it with the local registry. To keep things simple and
> > consistent, the key would match the resource. So, if you wanted to
> > retrieve the router, you'd use this:
> >
> > $router = $registry->router;
>
> How would it know which key name to use?
It would use the same key as the resource being called, cast to lower
case. So, for example, if bootstrap() calls the 'FrontController'
resource, it would store it in the 'frontcontroller' key of the
container. Same for the Router resource.
As long as you know what your resource names are, you know the keys.
> > In your action controllers, you'd use the following:
> >
> > $registry = $this->getInvokeArg('registry');
> > $router = $registry->router;
> >
>
> Looks good, though the InvokeArg's name could be clearer as 'registry'
> implies that it's to be used for all registry things.
I've actually changed this, based on some discussion in #zftalk.dev. The
current implementation is that the bootstrap stuffs itself into the
front controller, and you pull the bootstrap from there -- and the
container from the bootstrap:
$bootstrap = $this->getInvokeArg('bootstrap');
$router = $bootstrap->getResource('router');
I feel this is a slightly better, if more verbose, solution.
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论