0

can some one tell me how zend action helpers exactly work , i mean , even though i already used them in my code i feel some thing is missing in my understanding :

e.g. i have some thing like this

$this->_helper->viewRenderer->setRender('edit',null,true);

i my code , so that i will be able to render add-actions to use edit pages (since adding is the same as editing ..... on UI basis @ least )

but my question here is , as far as i can see the _helper is an instance of

/**
 * Helper Broker to assist in routing help requests to the proper object
 *
 * @var Zend_Controller_Action_HelperBroker
 */
protected $_helper = null;

but when i try to see in the library folder this class "Zend_Controller_Action_HelperBroker" i can't find a property named "viewRenderer"

1 Answer 1

2

The $_helper is a magical little thing that loads action helpers when needed. It looks in registered paths - which by default is Zend/Controller/Action/Helper - which is where you'll find the viewRenderer helper.

The fact that the class doesn't have a viewRenderer property is because the HelperBroker handles all requests via the magic __call method.

This call method looks for a helper (in this case viewRenderer) and calls the direct() method on that helper.

2
  • if i get you correctly does that mean i can call any of the methods found in this path "Zend/Controller/Action/Helper" by making $this->_helper->$one of the classes in that path then ->$any method in that path(i.e. in those classes) ( $$$ params );
    – jspeshu
    Dec 9, 2010 at 15:22
  • Your understanding is correct. You'll have to comment on the js answer.. I don't know which one you're referring to. Dec 9, 2010 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.