开发者

In Zend Framework applications, what purpose does the /views/filters serve?

I have an idea of what view helpers do (/view/helpers), but I have no idea what a view f开发者_JAVA技巧ilter (/view/filters) is, or what its used for, can some one please shed some light on the matter?

Thank You =)


At the end of rendering a view, Zend_View passes the output to any filter(s) you have registered, by calling the filter() method on the filter object.

One use of a filter could be to minify HTML output, stripping comments and whitespace to reduce the size of the content to send over the network.

In theory, you could write more sophisticated filters, that modify the DOM, altering, hiding or removing page elements. I wouldn't do that because it's more efficient for the view to render elements right on the first pass, than to tweak them with DOM operations after rendering. Or you could modify content, such as to translate English into French on the fly (if you had an automatic way of doing that, which ZF does not provide).

Zend_View filter is unfortunately undocumented, which makes me think there is little demand for it. I suspect that view filters are basically a victim of YAGNI. They were implemented without a good use case in mind.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜