This line was removed.
This word was removed. This word was added.
This line was added.

Changes (16)

View Page History
*Controller Use Case*

The Controller View Helper enables templates to dispatch any given Controller and Action. The contents of the Response object resulting from this dispatch is are then rendered in the calling template. Controller should never be used to alter the Model in this fashion - but are highly usable to enable the embedding of an existing Controller's output into an application.

Note: actions may either _forward() to another action or _redirect(). These are considered invalid responses, and result in an empty string being returned. Developers should be careful to only invoke actions that do not _forward() or _redirect().

* @package Zend_View
* @subpackage Helpers
* @copyright Copyright (c) 2007 Pádraic Brady (
* @license New BSD License
class Zend_View_Helper_Controller {
public $defaultModule;
public $dispatcher;
public $front;
public $request;
public $response;

* Dispatch a request via the Controller and fetch the resulting rendered
* View to return Constructor
* Initialize various helper objects and state.
* @param string $action
* @param string $controller @return void
* @param string $module
* @param array $params
* @returns string
* @todo Breaks with the ViewRenderer enabled (ZF-1545)
public function controller($action, $controller = null, $module = null, array $params = null)
public function __construct()
{} {
$this->front = Zend_Controller_Front::getInstance();
$this->request = clone $this->front->getRequest();
$this->response = clone $this->front->getResponse();
$this->dispatcher = clone $this->front->getDispatcher();
$this->defaultModule = $this->front->getDefaultModule();

* Reset state
* @return void
public function resetObjects()
// Should probably create a 'clearUserParams()' method...
$params = $this->request->getUserParams();
foreach (array_keys($params) as $key) {
$this->request->setUserParam($key, null);


* Invoke a controller component
* @param string $action Action name
* @param string $controller Controller name
* @param string $module Module name; defaults to default module name as registered in dispatcher
* @param array $params Additional parameters to pass in request object
* @return string
public function controller($action, $controller, $module = null, array $params = array())
if (null === $module) {
$module = $this->defaultModule;

$this->dispatcher->dispatch($this->request, $this->response);

if (!$this->request->isDispatched()
|| $this->response->isRedirect())
// forwards and redirects render nothing
return '';

return $this->response->getBody();