Reputation: 2752
How do I access baseUrl() from a helper class in zf ?
function validateSession ()
{
if (!$this->session->adminid)
{
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->setGotoSimple( $this->baseURL() .'/login');
$redirector->redirectAndExit();
}
}
$this->baseUrl()
doesn't work
Upvotes: 0
Views: 84
Reputation: 4615
You can redirect form a controller using any of the below method.
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
$redirector->gotoUrl('/url');
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
$redirector->gotoSimple('my-action',
'my-controller',
null,
array('param1' => 'test',
'param2' => 'test2'
)
);
Basically you have to get the Redirector
class/object of Zend and can apply any method they have specified in the manual zend.controller.actionhelpers.redirector
Upvotes: 1