I have a class in my library folder (My_Class) – it’s not a controller. I have TRY-CATCH block in it and I want to immediately redirect from CATCH block. It is possible to do it this way?
My_Class{
public function MyFunction(){
$this->MyOtherFunction();
//do more stuff
}
private function MyOtherFunciton(){
try{
//throw exception
} catch (Exception $e) {
$redirector = new Zend_Controller_Action_Helper_Redirector();
$redirector->gotoSimpleAndExit('action','controller','default');
}
}
It redirects, but does it redirect immediately? Or can “//do more stuff” be processed?
Thank you
PS: Class is called from controller:
//in controller
$myclass = new My_Class();
$myclass->MyFunction();
Yes it does redirect immediately. You can check it out yourself in the file
/Zend/Controller/Action/Helper/Redirector.php
There is also a gotoSimple() function that maybe does not redirect right away.