PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.1
GiveWP – Donation Plugin and Fundraising Platform v4.15.1
4.18.0.1 4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 All 258 releases
give / vendor / vendor-prefixed / symfony / http-foundation / Session / Flash / FlashBag.php

FlashBag.php in GiveWP – Donation Plugin and Fundraising Platform 4.15.1, at vendor/vendor-prefixed/symfony/http-foundation/Session/Flash/FlashBag.php

153 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Give\Vendors\Symfony\Component\HttpFoundation\Session\Flash;
13
14 /**
15 * FlashBag flash message container.
16 *
17 * @author Drak <[email protected]>
18 */
19 class FlashBag implements FlashBagInterface
20 {
21 private $name = 'flashes';
22 private $flashes = [];
23 private $storageKey;
24
25 /**
26 * @param string $storageKey The key used to store flashes in the session
27 */
28 public function __construct(string $storageKey = '_symfony_flashes')
29 {
30 $this->storageKey = $storageKey;
31 }
32
33 /**
34 * {@inheritdoc}
35 */
36 public function getName()
37 {
38 return $this->name;
39 }
40
41 public function setName(string $name)
42 {
43 $this->name = $name;
44 }
45
46 /**
47 * {@inheritdoc}
48 */
49 public function initialize(array &$flashes)
50 {
51 $this->flashes = &$flashes;
52 }
53
54 /**
55 * {@inheritdoc}
56 */
57 public function add(string $type, $message)
58 {
59 $this->flashes[$type][] = $message;
60 }
61
62 /**
63 * {@inheritdoc}
64 */
65 public function peek(string $type, array $default = [])
66 {
67 return $this->has($type) ? $this->flashes[$type] : $default;
68 }
69
70 /**
71 * {@inheritdoc}
72 */
73 public function peekAll()
74 {
75 return $this->flashes;
76 }
77
78 /**
79 * {@inheritdoc}
80 */
81 public function get(string $type, array $default = [])
82 {
83 if (!$this->has($type)) {
84 return $default;
85 }
86
87 $return = $this->flashes[$type];
88
89 unset($this->flashes[$type]);
90
91 return $return;
92 }
93
94 /**
95 * {@inheritdoc}
96 */
97 public function all()
98 {
99 $return = $this->peekAll();
100 $this->flashes = [];
101
102 return $return;
103 }
104
105 /**
106 * {@inheritdoc}
107 */
108 public function set(string $type, $messages)
109 {
110 $this->flashes[$type] = (array) $messages;
111 }
112
113 /**
114 * {@inheritdoc}
115 */
116 public function setAll(array $messages)
117 {
118 $this->flashes = $messages;
119 }
120
121 /**
122 * {@inheritdoc}
123 */
124 public function has(string $type)
125 {
126 return \array_key_exists($type, $this->flashes) && $this->flashes[$type];
127 }
128
129 /**
130 * {@inheritdoc}
131 */
132 public function keys()
133 {
134 return array_keys($this->flashes);
135 }
136
137 /**
138 * {@inheritdoc}
139 */
140 public function getStorageKey()
141 {
142 return $this->storageKey;
143 }
144
145 /**
146 * {@inheritdoc}
147 */
148 public function clear()
149 {
150 return $this->all();
151 }
152 }
153