本文整理汇总了PHP中Nette\Application\UI\Presenter::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Presenter::redirect方法的具体用法?PHP Presenter::redirect怎么用?PHP Presenter::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Presenter
的用法示例。
在下文中一共展示了Presenter::redirect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newWriterFormSucceeded
public function newWriterFormSucceeded($form, $values)
{
if (!$this->presenter->user->isLoggedIn()) {
try {
$this->captchaManager->checkCaptcha($values->captcha);
} catch (\Exception $e) {
$this->presenter->flashMessage($e->getMessage());
$this->presenter->redirect('this');
}
$values->byUser = null;
} else {
$values->contact = $this->presenter->user->getIdentity()->mail;
$values->byUser = $this->presenter->user->id;
}
try {
$this->articleManager->addNewWriter($values);
} catch (\Exception $e) {
$form->addError($e->getMessage());
}
}
示例2: create
/**
* @param string $name
* @param Selection $selection
* @param bool $processForm
* @return mixed
* @throws FormNotExistsException
*/
public function create($name, Selection $selection, $processForm = TRUE)
{
$className = '\\App\\AdminModule\\Form\\' . $name;
if (!class_exists($className)) {
throw new FormNotExistsException("Form class {$className} does not exist!");
}
if ($this->presenter === NULL) {
throw new InvalidArgumentException('Presenter must be set!');
}
$form = new $className($this->db, $selection);
if ($processForm) {
$form->onSuccess[] = function ($form) {
$form->process();
if ($form->valid && !$form->hasErrors()) {
$this->presenter->flashMessage('Úspěšně uloženo', 'success');
$this->presenter->redirect('this');
}
};
}
return $form;
}