| Conditions | 4 |
| Paths | 4 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | protected function flashMessage($type, $message = null) |
||
| 13 | { |
||
| 14 | $supportedTypes = [self::$flashSuccess, self::$flashInfo, self::$flashWarning, self::$flashDanger]; |
||
| 15 | if (!in_array($type, $supportedTypes)) { |
||
| 16 | throw new \LogicException(sprintf('""%s" type is not supported')); |
||
| 17 | } |
||
| 18 | if (!$this->container->has('session')) { |
||
| 19 | throw new \LogicException('You can not use the addFlash method if sessions are disabled.'); |
||
| 20 | } |
||
| 21 | if (!$message) { |
||
| 22 | $message = $this->get('translator')->trans('flash.'.$type.'.message', [], 'common'); |
||
|
|
|||
| 23 | } |
||
| 24 | |||
| 25 | $this->container->get('session')->getFlashBag()->add($type, $message); |
||
| 26 | } |
||
| 28 |