Example #1
0
 /**
  * @param AbstractDialog $dialog
  * @return Application\UI\Link|UrlScript
  */
 public function getReturnLink(AbstractDialog $dialog = NULL)
 {
     $destination = $this->config->getReturnDestination();
     if ($destination[0] instanceof Url) {
         return $destination[0];
     }
     $reset = array();
     /** @var Application\UI\Presenter $presenter */
     $presenter = $this->app->getPresenter();
     /** @var PresenterComponent $parent */
     $parent = $dialog ? $dialog->getParent() : $presenter;
     do {
         $prefix = $parent instanceof Application\IPresenter ? '' : $parent->lookupPath('Nette\\Application\\IPresenter');
         foreach ($parent->getReflection()->getPersistentParams() as $name => $meta) {
             $reset[($prefix ? $prefix . IComponent::NAME_SEPARATOR : '') . $name] = array_key_exists('def', $meta) ? $meta['def'] : NULL;
         }
     } while ($parent = $parent->getParent());
     $args = is_array($destination[1]) ? $destination[1] : array_slice($destination, 1);
     if ($dialog !== NULL) {
         $args['do'] = $dialog->lookupPath('Nette\\Application\\IPresenter') . IComponent::NAME_SEPARATOR . 'response';
     }
     return $presenter->lazyLink('//' . ltrim($destination[0], '/'), $args + $reset);
 }