Notifications by SweetAlert2 (#1508)
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user