Skip to content

Commit

Permalink
Control::flashMessage accepts custom flash object
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 16, 2020
1 parent 67edb5b commit ea5ac15
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Application/UI/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,17 @@ public function templatePrepareFilters(ITemplate $template): void

/**
* Saves the message to template, that can be displayed after redirect.
* @param string|\stdClass $message
*/
public function flashMessage($message, string $type = 'info'): \stdClass
{
$id = $this->getParameterId('flash');
$messages = $this->getPresenter()->getFlashSession()->$id;
$messages[] = $flash = (object) [
$flash = $message instanceof \stdClass ? $message : (object) [
'message' => $message,
'type' => $type,
];
$messages = $this->getPresenter()->getFlashSession()->$id;
$messages[] = $flash;
$this->getTemplate()->flashes = $messages;
$this->getPresenter()->getFlashSession()->$id = $messages;
return $flash;
Expand Down

0 comments on commit ea5ac15

Please sign in to comment.