开发者

zend view: bootstrap(view) or bootstrap(layout)

These are 2 different implementations for an _init function in the bootstrap related to bootstrapping the view.开发者_Go百科

One gets at the view right away: bootstrap('view') then gets it as a resource

$this->bootstrap('view');
$view = $this->getResource('view');
$view->doctype('XHTML1_STRICT');

The other one takes a longer route through the layout bootstrap('layout')

$this->bootstrap('layout');        
$layout = $this->getResource('layout');
$view = $layout->getView();
$view->doctype('XHTML1_STRICT');

I don't want to judge the longer code as inefficient just because it's longer. Is there something it adds by going through the layout first instead of hitting the view right away?


The short answer is no, not really.

With Zend Application the $view referenced in either way is the same object. As the layout and view are inherently related you can retrieve the view from the layout.

For your own sanity, the first one is more concise and quicker to comprehend.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜