public function link($destination, $array = array()) { if (strpos($destination, ":") !== FALSE) { $control = $this->lookup('Nette\\Application\\Presenter', TRUE); return $control->link($destination, $array); } else { return parent::link($destination, $array); } }
/** * Generates link. If links points to @secure annotated signal handler method, additonal * parameter preventing changing parameters will be added. * * @param string $destination * @param array|mixed $args * @return string */ public function link($destination, $args = array()) { if (!is_array($args)) { $args = func_get_args(); array_shift($args); } $link = parent::link($destination, $args); $lastrequest = $this->presenter->lastCreatedRequest; /* --- Bad link --- */ if ($lastrequest === NULL) { return $link; } /* --- Not a signal --- */ if (substr($destination, -1) !== '!') { return $link; } /* --- Exclude Form submits --- */ if (substr($destination, -8) === '-submit!') { return $link; } /* --- Only on same presenter --- */ if ($this->getPresenter()->getName() !== $lastrequest->getPresenterName()) { return $link; } $signal = trim($destination, '!'); $rc = $this->getReflection()->getMethod($this->formatSignalMethod($signal)); // if (Annotations::has($rc, 'secured') === FALSE) { if ($rc->hasAnnotation('secured') === FALSE) { return $link; } $origParams = $lastrequest->getParams(); $protectedParams = array(); foreach ($rc->getParameters() as $param) { $protectedParams[$param->name] = ArrayTools::get($origParams, $this->getParamId($param->name)); } $args['__secu'] = $this->createSecureHash($protectedParams); return parent::link($destination, $args); }