19 class AutoExpireFlashBag
implements FlashBagInterface
21 private $name =
'flashes';
22 private $flashes = [
'display' => [],
'new' => []];
28 public function __construct(
string $storageKey =
'_symfony_flashes')
30 $this->storageKey = $storageKey;
51 $this->flashes = &$flashes;
56 $this->flashes[
'display'] = \array_key_exists(
'new', $this->flashes) ? $this->flashes[
'new'] : [];
57 $this->flashes[
'new'] = [];
63 public function add($type, $message)
65 $this->flashes[
'new'][$type][] = $message;
71 public function peek($type, array $default = [])
73 return $this->
has($type) ? $this->flashes[
'display'][$type] : $default;
81 return \array_key_exists(
'display', $this->flashes) ? (array) $this->flashes[
'display'] : [];
87 public function get($type, array $default = [])
91 if (!$this->
has($type)) {
95 if (isset($this->flashes[
'display'][$type])) {
96 $return = $this->flashes[
'display'][$type];
97 unset($this->flashes[
'display'][$type]);
108 $return = $this->flashes[
'display'];
109 $this->flashes[
'display'] = [];
119 $this->flashes[
'new'] = $messages;
125 public function set($type, $messages)
127 $this->flashes[
'new'][$type] = (array) $messages;
133 public function has($type)
135 return \array_key_exists($type, $this->flashes[
'display']) && $this->flashes[
'display'][$type];
143 return array_keys($this->flashes[
'display']);
151 return $this->storageKey;