2009年2月12日星期四

Re: [fw-mvc] Objects Availability

In reality the best way, without using a service locater or registry, would be to use some kind of DI container. In order to truly integrate this into zend, you would either have to create a new dispatcher which creates the controller from the DI container instead of instantiating itself (similar to the way i've seen it done in ASP.NET MVC tutorials using the ASP.NET Controller Factory, or with an action helper which injects it via setters in the preDispatch stage (similar to the way its handled in struts2 or stripes, I believe...a special action helper would have to be made for any given DI container)

On Fri, Feb 13, 2009 at 12:00 AM, Cristian Bichis <contact@zftutorials.com> wrote:
That's quite a good question. Trying to find out the best approach myself.

Currentyl i have my own My_Controller_Action or My_View, derived from Zend ones. So each controller class or view i am using into project is derived from those two classes. This is my approach, i am pretty sure is not the best...

Anyway, keep in mind in views you should'nt make available more tthan what's really needed...


--
Best regards,
Cristian Bichis
www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com



What's the best way to make objects available "globally"? I mean
available in the following:

1) In action controllers;
2) In Forms;
3) In Views;

Sure I can use registry and then assign these objects to the views
and/or forms in action controllers but what if I want to make these
objects automatically assigned to ALL action controllers, views and
forms in the project?


 



没有评论: