Sonny
Sonny

Reputation: 8326

Zend Controller Action: _redirect() vs getHelper('Redirector')->gotoUrl()

I've read that $this->getHelper('[helper_name]') is preferable to $this->_helper->[helper_name]. What I haven't been able to find any documentation of is which of these is better/preferred: $this->_redirect($url) or $this->getHelper('Redirector')->gotoUrl($url).

Upvotes: 4

Views: 7338

Answers (1)

Aron Rotteveel
Aron Rotteveel

Reputation: 83173

Use whatever one suits you, they do exactly the same thing:

/**
 * Redirect to another URL
 *
 * Proxies to {@link Zend_Controller_Action_Helper_Redirector::gotoUrl()}.
 *
 * @param string $url
 * @param array $options Options to be used when redirecting
 * @return void
 */
protected function _redirect($url, array $options = array())
{
    $this->_helper->redirector->gotoUrl($url, $options);
}

Upvotes: 5

Related Questions