本文整理汇总了PHP中Nette\Application\UI\Presenter::flashMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Presenter::flashMessage方法的具体用法?PHP Presenter::flashMessage怎么用?PHP Presenter::flashMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Presenter
的用法示例。
在下文中一共展示了Presenter::flashMessage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: flashMessage
/**
* Saves the message to template, that can be displayed after redirect
*
* @param string
* @param string
* @return stdClass
*/
public function flashMessage($message, $type = 'info')
{
$types = $this->getContext()->params['flashes'];
if (isset($types[$type])) {
$type = $types[$type];
}
return parent::flashMessage($message, $type);
}
示例2: 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());
}
}
示例3: flashMessage
/**
* @param string
* @param string
* @param bool
* @return \stdClass
*/
public function flashMessage($message, $type = 'info', $withoutSession = FALSE)
{
if ($withoutSession) {
$this->_flashes[] = $flash = (object) array('message' => $message, 'type' => $type);
} else {
$flash = parent::flashMessage($message, $type);
}
$id = $this->getParameterId('flash');
$messages = $this->getPresenter()->getFlashSession()->{$id};
$this->getTemplate()->flashes = array_merge((array) $messages, $this->_flashes);
return $flash;
}
示例4: 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;
}
示例5: hasFileError
/**
* Return file upload error message.
* @param FileUpload $file
* @param UI\Presenter $presenter
* @return bool
*/
public static function hasFileError(FileUpload $file, UI\Presenter &$presenter, $noFileError = TRUE)
{
switch ($file->getError()) {
case UPLOAD_ERR_INI_SIZE:
$presenter->flashMessage('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'error');
$return = FALSE;
break;
case UPLOAD_ERR_FORM_SIZE:
$presenter->flashMessage('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', 'error');
$return = FALSE;
break;
case UPLOAD_ERR_PARTIAL:
$presenter->flashMessage('The uploaded file was only partially uploaded.', 'error');
$return = FALSE;
break;
case UPLOAD_ERR_NO_FILE:
if ($noFileError === FALSE) {
$presenter->flashMessage('No file was uploaded.', 'error');
}
$return = $noFileError;
break;
case UPLOAD_ERR_NO_TMP_DIR:
$presenter->flashMessage('Missing a temporary folder.', 'error');
$return = FALSE;
break;
case UPLOAD_ERR_CANT_WRITE:
$this->flashMessage('Failed to write file to disk.', 'error');
$return = FALSE;
break;
case UPLOAD_ERR_EXTENSION:
$presenter->flashMessage('File upload stopped by extension.', 'error');
$return = FALSE;
break;
default:
$presenter->flashMessage('Chyba při zpracování souboru ' . $file->getName(), 'error');
$return = FALSE;
break;
}
return $return;
}
示例6: flashMessage
/**
* @param string|array
* @param string
* @param \Exception|NULL $e
* @return \stdClass
*/
public function flashMessage($message, $type = 'info', \Exception $e = NULL)
{
if (is_array($message)) {
$el = (string) Html::el()->setHtml(array_shift($message));
if (strpos($el, '%') !== FALSE) {
$el = preg_replace_callback('/%([bius])%/', function ($m) use(&$message) {
if (count($message)) {
return (string) Html::el($m[1] === 's' ? NULL : $m[1])->setText(array_shift($message));
}
}, $el);
}
$el = Html::el()->setHtml($el);
} else {
$el = Html::el()->setText($message);
}
if ($e) {
$el = Html::el()->add($el)->add(Html::el('br'))->add(Html::el('small')->setText($e->getMessage()));
}
return parent::flashMessage($el, $type);
}
示例7: flashMessage
/**
* @param string $message
* @param string $type
* @param string $title
* @return \stdClass
*/
public function flashMessage($message, $type = Flash::SUCCESS, $title = '')
{
$message = $this->translator->translate($message, null, ['AHOJ']);
$flash = parent::flashMessage($message, $type);
switch ($type) {
case Flash::SUCCESS:
$flash->title = 'Výborně!';
break;
case Flash::ERROR:
$flash->title = 'Chyba!';
break;
case Flash::INFO:
$flash->title = 'Informace!';
break;
case Flash::WARNING:
$flash->title = 'Upozornění!';
break;
default:
$flash->title = $title;
break;
}
return $flash;
}
示例8: flashMessage
public function flashMessage($message, $type = "info")
{
$message = $this->translator->translate($message);
return parent::flashMessage($message, $type);
}
示例9: flashMessage
/**
* Additionally redraws snippet with flash messages.
*
* @param $message
* @param string $type
* @return \stdClass|void
*/
public function flashMessage($message, $type = 'info')
{
parent::flashMessage($message, $type);
$this['flashMessage']->redrawControl();
}