Most of what you're suggesting is already possible with the current
view and front controller.
I do like the view plugins idea. Although front controller plugins
are capable of the same functions, this seems like it would make some
tasks simpler. Whether or not its worth the added complexity is
debatable.
Views already have helpers, with which wrappers and 'filters' could
be implemented.
ViewRenderer can already be replaced with your own class with the
Zend_Controller_Action_HelperBroker. Although I've never liked the
way the ViewRenderer is named (34 characters is a tad verbose) its
current implementation does have some real advantages.
- Nathan.
On 9-Jun-07, at 5:49 PM, pat wrote:
To List,
I’m not happy with the current View implementation. First I’ll
layout my criticism, then suggest what I think may be an answer. I
realize this won’t make it into the next release or anything like
that but, I would like to know what people think about it
Basically, what I want is for the View to be more like the
Controller. I want it beefier, meatier, able to stand on its own
as part of the MVC. The MVC needs more V. As things stand now,
the View has all but disappeared into the Controller’s Action
helper. It needs to be brought out and made a powerful component
in its own right.
The viewRenderer should be a plug-in for the View, not the other
way around. The viewRenderer should be to the View, what the
router is to the Front Controller. People could then use a default
viewRenderer or slot in a custom viewRenderer, just as they now can
change routers.
The View should be able to host plug-ins like the Front Controller
does. The plug-ins could have methods like preRender, postRender
to allow for such things as selecting skins for the page
(preRender) or running the page through tidy (postRender).
The view should have helpers. In particular, there are two helper
classes worth considering. View_Wrappers and View_Filters.
Wrappers add to, filters take away.
Suppose you have a row from a database and you only want the 1st,
3rd and 5th . You might write:
$info = filter(array(‘1’,’3’,’5’), $row);
A wrapper might follow the decorator pattern and do something like
this:
$list = wrap(‘list’,$array); // creates an html list out of an array
Wrappers can be chained together.
There are lots of things to be puzzled out, but the above is the
gist.
Implementation shouldn’t be too hard. Much of the design for plug-
ins and such can come from the Front Controller. Instead of
extending the view class, a new class named Zend_Alternative_View
or something could be used. This way you could use the old View
while proto-typing the new Zend_Alternative_View.
So, what do you say? Could it be ready for Zend 2.0?
Pat.