File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,8 +52,12 @@ class Messages
5252 * @throws RuntimeException if the session cannot be found
5353 * @throws InvalidArgumentException if the store is not array-like
5454 */
55- public function __construct (&$ storage = null )
55+ public function __construct (&$ storage = null , $ storageKey = null )
5656 {
57+ if (is_string ($ storageKey ) && $ storageKey ) {
58+ $ this ->storageKey = $ storageKey ;
59+ }
60+
5761 // Set storage
5862 if (is_array ($ storage ) || $ storage instanceof ArrayAccess) {
5963 $ this ->storage = &$ storage ;
Original file line number Diff line number Diff line change @@ -269,4 +269,14 @@ public function testClearMessage()
269269 $ this ->assertFalse ($ flash ->hasMessage ('Now ' ));
270270 $ this ->assertTrue ($ flash ->hasMessage ('Foo ' ));
271271 }
272+
273+ public function testSettingCustomStorageKey ()
274+ {
275+ $ storage = ['some-key ' => [ 'Test ' => ['Test ' ]]];
276+ $ flash = new Messages ($ storage );
277+ $ this ->assertFalse ($ flash ->hasMessage ('Test ' ));
278+
279+ $ flash = new Messages ($ storage , 'some-key ' );
280+ $ this ->assertTrue ($ flash ->hasMessage ('Test ' ));
281+ }
272282}
You can’t perform that action at this time.
0 commit comments