2012-02-09 18 views
0

我在我的庫文件夾(My_Class)中有一個類 - 它不是控制器。我有TRY-CATCH塊,我想立即從CATCH塊重定向。可以這樣做嗎?Zend控制器之外的重定向器

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'); 
      } 


     } 

它重定向,但它立即重定向?或者可以「處理更多的東西」? 謝謝

PS:類是從控制器稱爲:

//in controller 
    $myclass = new My_Class(); 
    $myclass->MyFunction(); 

回答

3

是它並立即重定向。你可以在文件中自己檢查它 /Zend/Controller/Action/Helper/Redirector.php

還有一個gotoSimple()函數可能不會馬上重定向。

0
setExit() can be used to force an exit() following a redirect. By default this is TRUE. 

你可以嘗試$redirector->setExit(false)->setGotoSimple(),我從來沒有過這樣的原因我沒有嘗試過這個功能了重定向後,做任何事情。