The fundamental reason why the ActionStack is considered evil is because
the limitations the current Controller+View implementation. There is a
certain amount of complexity in the Zend_Controller implementation that
allows for some out-of-the-box easy use scenarios. ALso,
Zend_Controller and Zend_View are completely standalone components, with
a lot of awareness of each other- as opposed to a components that
handles both controller tasks and view tasks together (like a Zend_MVC
component might do).
That said, since Zend_Controller does do alot by defualt, and that it
shares a certain global state (Zend_Controller is a singleton) and makes
it harder to attain a PAC or hMVC style architecture:
http://en.wikipedia.org/wiki/Presentation-abstraction-control
In short, it is very hard to have an MVC kernel within an MVC kernel
where they share no state at all with one another.
On the other hand, the only use case that actually comes to mind for
this style of architecture is building a portal - which is the sum of
many portlets.
Another interesting note is that you dont really have to have a
controller at all in portals. A controller's duty should be limited to
parsing the environment and from that environment, determining which
models to instantiate and pass onto which views. That said, it makes a
lot of sense, in building a portal, to build a Portal model that can be
called to handle the task of finding the proper sub models, assinging
them to a view and returning that content back to the response object.
To try and sum that up, there is no need for MVC's within an MVC since
you don't need a C in the portlets. ANd the reason you don't need the C
is b/c that code generally would not need access to any environment
specific stuff like $_POST or $_GET, as that would have been handed by
the top most controller.
So thats a bit of the high level overview of what ActionStack attempted
to solve, and the problems it runs into trying to solve that problem.
-ralph
Christian Ehmig wrote:
> I've read some discussions about the "evil" ActionStack in this forum and
> specifically here:
> http://www.rmauger.co.uk/2009/03/why-the-zend-framework-actionstack-is-evil/
>
> I commented on that (#19).
>
> Now my question is - how do you setup Zend MVC for complex, highly
> configurable websites or portals (not only simple blog applications with
> basic CRUD operations). In particular, websites that consist of many conrete
> pages that make use of (hopefully) reusable components.
>
> For me the best solution is still:
>
> 1. Writing a Zend_Controller_Plugin that hooks into routeShutdown()
> 2. in routeShutdown() compile the set of actions, their parameters,
> templates and layout targets from a given page configuration (xml file,
> database) and the layout file to be used for that page
> 3. Push these actions to the ActionStack
> 4. done
>
> Any other approaches seem not reusable and "hard-coded" for me. I can give
> further details on my implementation if needed. I am just curious how others
> solve the issue "a page consists of several actions and their respective
> views".
没有评论:
发表评论