We often come across a problem in Zend framework where we need add on demand functionality into any Action Controller. In Zend framework, Action Helpers allows to do the same thing.
Basically Action Helpers helps to inject common Action Controller functionality in to any action with out extending the abstract Action Controller for common functionality.
In below e.g. I have created a custom action helper where I need to get firstname of user based on his userid.
class Zend_Controller_Action_Helper_User extends Zend_Controller_Action_Helper_Abstract
{
public function firstName( $userid = null ) {
//fetch from database and return
}
}
How to call an Action helper in the Action Controller :
$firstName = $this->_helper->user->firstName( 'abc' );
References:
http://framework.zend.com/manual/en/zend.controller.actionhelpers.html
http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelper.writingyourown
1 comment:
We often come across a problem in Zend framework where we need add on demand functionality into any Action Controller. In Zend framework, Action Helpers allows to do the same thin
Post a Comment