-- Bruno B. B. Magalhaes <[email protected]> wrote
(on Saturday, 11 July 2009, 04:18 PM -0300):
> first of all, this is my first post on this list, but I've been using  
> this framework for a long time, since it's very early stages, and it has 
> been very fun since...
>
> Yesterday I was working in a new client's infrastructure (we have to by 
> contract) for a very large company in Brazil, and I had a simple idea 
> when using a registry with variable scopes... For example the controller 
> can only access the instances of database, router, request and response, 
> the plugin can only use the configuration, database, request and response 
> objects... How to deal with this kind of variable scope registry... Here 
> is my suggestion:

<snip -- code snippets>

> We would add instances to the registry like:
> Application('Configuration', new Zend_Config());
> Controller('Configuration', Application('Configuration'));
> Plugin('Configuration', Application('Configuration'));
>
> So we are able to use it like this, inside of a controller:
>
> Application('Configuration')->GerParameter('application.address'); OR
> Controller('Configuration')->GerParameter('application.address');
>
> Os if this is available inside the plugin, we can use:
>
> Application('Configuration')->GerParameter('application.address'); OR
> Plugin('Configuration')->GerParameter('application.address');
>
> Maybe we could have a function called Zend(), to "abstract" the Zend  
> Registry? It makes the code extremely readable and fluid... Guys, am I  
> crazy? Is this a pattern of somehow? :D

It's a filtering registry, basically. You can create similar
functionality by extending Zend_Registry to add filtering -- I've seen
people do both that as well as create a combination Registry/Factory
that will lazy load objects if they don't exist in the registry already.

This is a pretty specialized use case, and I'm not sure if has a place
within ZF itself.

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

Reply via email to