开发者

Zend Framework: Application.ini what does resources.view[] = do?

i am wondering what does adding ...

resources.view[] = 

... init application.ini actually do?

i know it allows me to access the view from bootstrap by

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

but i开发者_运维技巧 wonder how does zf know resources.view = zend view? i guess doing that and accessing $view by getResource('view') will create a view initialized using the zend view plugin?

if i dont add the line resources.view[] = my app still has a zend view right? so why is that line required, just to get the view resource?


That line triggers bootstrapping of the View resource, see:

http://framework.zend.com/manual/en/zend.application.available-resources.html#zend.application.available-resources.view

it allows you to set a load of options (doctype, encoding etc.) via. the application.ini.

Without that line you will still have a view yes, as the viewRenderer will create a View object on demand when it is first required.


The :

resources.view[] =

in ini file is equal to php's empty array:

array(
    'resources' => array(
         'view' => array()  // pass empty array of the view options
    )
)

The Bootstrap checks whether the resources array is null, so if you pass an empty array, you pass no options, but the comparison result is not null, which results in running the view resource, but without any options.

To have the same effect, you could do:

resources.view.enabled = 1

But this sends option enabled to the view resource.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜