The request object contains the name of the module, controller, action and the request parameters. Sometimes, you might want to access the request object outside the controller or controller plugin.
For example a user on #zftalk just asked
"how can I access request object within form's method?"
The front controller instance is a singleton. This means we can get the instance of the front controller from any part of our application using the static method getInstance().
To grab the front controller instance use:
<?php
$frontController = Zend_Controller_Front::getInstance();
?>We can access the request object from the front controller intance:
$request = $frontController->getRequest();
Using the fluent interface you can access the front controller in a single line:
$request = Zend_Controller_Front::getInstance()->getRequest();
If you want to access the front controller in your action just use:
$request = $this->getRequest();
Post new comment