2010年2月21日星期日

Re: [fw-mvc] Re: How to extend Zend_View?

Hi,

resources in bootstrap are called once. They can be in form of _initXyz() methods in Bootstarp.php or separate classes. You do not need to add anything to bootstrap() method (usually). You can use bootstrap methods to do things like:

public function _initSomething()
{
   $view = $this->bootstrap('view')->getResource('view');

   $view->test = 'value';
}

First line of this method works like dependency checker - sometimes getResource() is only required to be called as view could be already instantiated, but adding bootstrap() will make sure that it is in fact instantiated. 

So as you can see - by modifying bootstrap() method (or _boostrap()) you kind of naively rely on the fact that it's only going to be called once. As noted above - add your logic to _init methods or separate resources and you'll be fine ;)

--
Juozas Kaziukėnas (juozas@juokaz.com)
Aš internete - JuoKaz (http://www.juokaz.com)


On Sun, Feb 21, 2010 at 9:23 PM, electrotype <electrotype@gmail.com> wrote:

Thanks Juozas, your solution works great indeed!

But can you tell me more about the _bootstrap() method which can be called
more than once during a request?

Where should I place my application initialization stuff, that should be run
only once, if the bootstrap is not the appropriated place?
--
View this message in context: http://n4.nabble.com/How-to-extend-Zend-View-tp1563653p1563828.html
Sent from the Zend MVC mailing list archive at Nabble.com.


没有评论: