开发者

What $this->bootstrap('view') will do?

开发者 https://www.devze.com 2023-02-22 07:00 出处:网络
I am new to zend framework. I found code in bootstrap file as below. protected function _i开发者_如何学编程nitDoctype()

I am new to zend framework. I found code in bootstrap file as below.

 protected function _i开发者_如何学编程nitDoctype()
    {
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
    }

can anyone explain me what "$this->bootstrap('view');" this mean?


From the same page where your snippet comes:

Now that we have a view, let's flesh out our _initDoctype() method. In it, we will first ensure the View resource has run, fetch the view object, and then configure it.


It sets up the view resource so that you can access it. Without it the following line would not return anything to put in the $view variable and you'd get the error:

Fatal error: Call to a member function doctype() on a non-object.


It's pretty straightforward, it literally bootstraps the View object.
Bootstraping is a step where you set up (configure and instantiate) your object, resolve dependencies, etc.
It is done because the View Object must be set before to be able to set a Doctype.

0

精彩评论

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

关注公众号