Jimit
Jimit

Reputation: 2259

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

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

 protected function _initDoctype()
    {
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
    }

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

Upvotes: 0

Views: 1073

Answers (3)

Boris Guéry
Boris Guéry

Reputation: 47585

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.

Upvotes: 1

fabrik
fabrik

Reputation: 14365

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.

Upvotes: 4

Gnuffo1
Gnuffo1

Reputation: 3546

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.

Upvotes: 3

Related Questions