예제 #1
0
 /**
  * Redirect to another presenter, action or signal.
  * @param  int      [optional] HTTP error code
  * @param  string   destination in format "[[module:]presenter:]view" or "signal!"
  * @param  array|mixed
  * @return void
  * @throws Nette\Application\AbortException
  * @throws Nette\InvalidStateException
  */
 public function redirect($code, $destination = NULL, $args = array())
 {
     if (!$this->actionHandled && $this->renderCalled) {
         throw new Nette\InvalidStateException("You cannot use redirect when no signal is called. Use " . get_called_class() . "::changeView() instead.");
     }
     // Pokud redirectujeme na Nette lazy link, nesmime pouzit jeho serializaci,
     // protoze generuje URL pomoci Presenter::createRequest v LINK modu.
     // To neprenasi flash session ID. Zpravicky ale potrebujeme zachovavat.
     // Proto musime vygenerovat pozadavek znovu
     if (func_num_args() == 1 && $code instanceof Nette\Application\UI\Link) {
         $link = $code;
         // Potrebujeme znat komponentu
         if (!$link instanceof vBuilder\Application\UI\Link) {
             throw new \LogicException("Perhaps wanted to pass vBuilder\\Application\\UI\\Link instead of Nette one?");
         }
         $link->component->redirect($link->destination, $link->getParameters());
         return;
     } else {
         if (func_num_args() < 3) {
             $args = $destination;
             $destination = $code;
             $code = NULL;
         }
     }
     if ($destination == 'this') {
         $destination = $this->view;
     }
     if ($code) {
         parent::redirect($code, $destination, $args);
     } else {
         parent::redirect($destination, $args);
     }
 }