Notifications by SweetAlert2 (#1508)

This commit is contained in:
Kevin Papst
2020-10-02 19:37:30 +02:00
committed by GitHub
parent 0aa6baea2f
commit 825e492891
21 changed files with 161 additions and 62 deletions

View File

@@ -79,6 +79,44 @@ abstract class AbstractController extends BaseAbstractController implements Serv
$this->addFlashTranslated('error', $translationKey, $parameter);
}
/**
* Adds an exception flash message for failed update/create actions.
*
* @param \Exception $exception
*/
protected function flashUpdateException(\Exception $exception)
{
$this->flashException($exception, 'action.update.error');
}
/**
* Adds an exception flash message for failed delete actions.
*
* @param \Exception $exception
*/
protected function flashDeleteException(\Exception $exception)
{
$this->flashException($exception, 'action.delete.error');
}
/**
* Adds a "error" flash message and logs the Exception.
*
* @param \Exception $exception
* @param string $translationKey
* @param array $parameter
*/
protected function flashException(\Exception $exception, string $translationKey, array $parameter = [])
{
$this->logException($exception);
if (!\array_key_exists('%reason%', $parameter)) {
$parameter['%reason%'] = $exception->getMessage();
}
$this->addFlashTranslated('error', $translationKey, $parameter);
}
/**
* Adds a fully translated (both $message and all keys in $parameter) flash message to the stack.
*