2008年12月5日星期五

[fw-mvc] Persistence of view helpers

If a view helper is istantiated, it will persist and be recycled when other calls to $this->helperName() are made. However, it's the broker that instantiates the helper and so I cannot pass anything in the constructor to modify my helper behaviour. For example I'd like to build a view helper that access a particular model (a simple name=>value table) but I do not want the helper to make queries when I jave already the model in the bootstrap and I can pass it in, nor instantiating another time the model in the view helper constructor.
A static field is not a nice solution, it's already diffucult to test controllers; maybe I can subclass the broker or similar to add an addHelper() method like the Zend_Controller_Action_HelperBroker one. What can be a viable solution?

--
Giorgio Sironi
Piccolo Principe & Ossigeno Scripter
http://www.sourceforge.net/projects/ossigeno

没有评论: