Tuhin Paul
Tuhin Paul

Reputation: 309

Object operators in zend framework

A noob question

$this->_helper->viewRenderer->setNoRender();

The above line is taken from indexController's init method in a tutorial that I have been following. Does the code sample really mean execute "setNoRender" method from viewRenderer object from _helper object from zend_Controller_Action object? Or is there a code writing convention specific to zend framework that I am unaware of?

Upvotes: 0

Views: 65

Answers (1)

Venu
Venu

Reputation: 7289

Its not a zend convention. Its a PHP syntax.

$this refers to current obj. Using -> operator you can access its properties or methods.

Does the code sample really mean execute "setNoRender" method from viewRenderer object from _helper object from zend_Controller_Action object?

Yes you are correct.

$this->_helper->viewRenderer->setNoRender();

This will disable the view, it is very useful when you using an ajax request.

FYI: Zend Controller action

The primary reasons to disable the ViewRenderer are if you simply do not need a view object or if you are not rendering via view scripts (for instance, when using an action controller to serve web service protocols such as SOAP, XML-RPC, or REST). In most cases, you will never need to globally disable the ViewRenderer, only selectively within individual controllers or actions.

Upvotes: 1

Related Questions