本文整理匯總了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;
}