@@ -36,6 +36,16 @@ class Session implements SessionInterface
36
36
*/
37
37
protected $ storage ;
38
38
39
+ /**
40
+ * @var string
41
+ */
42
+ private $ flashName ;
43
+
44
+ /**
45
+ * @var string
46
+ */
47
+ private $ attributeName ;
48
+
39
49
/**
40
50
* Constructor.
41
51
*
@@ -46,8 +56,14 @@ class Session implements SessionInterface
46
56
public function __construct (SessionStorageInterface $ storage = null , AttributeBagInterface $ attributes = null , FlashBagInterface $ flashes = null )
47
57
{
48
58
$ this ->storage = $ storage ?: new NativeSessionStorage ();
49
- $ this ->registerBag ($ attributes ?: new AttributeBag ());
50
- $ this ->registerBag ($ flashes ?: new FlashBag ());
59
+
60
+ $ attributeBag = $ attributes ?: new AttributeBag ();
61
+ $ this ->attributeName = $ attributeBag ->getName ();
62
+ $ this ->registerBag ($ attributeBag );
63
+
64
+ $ flashBag = $ flashes ?: new FlashBag ();
65
+ $ this ->flashName = $ flashBag ->getName ();
66
+ $ this ->registerBag ($ flashBag );
51
67
}
52
68
53
69
/**
@@ -63,55 +79,55 @@ public function start()
63
79
*/
64
80
public function has ($ name )
65
81
{
66
- return $ this ->storage ->getBag (' attributes ' )->has ($ name );
82
+ return $ this ->storage ->getBag ($ this -> attributeName )->has ($ name );
67
83
}
68
84
69
85
/**
70
86
* {@inheritdoc}
71
87
*/
72
88
public function get ($ name , $ default = null )
73
89
{
74
- return $ this ->storage ->getBag (' attributes ' )->get ($ name , $ default );
90
+ return $ this ->storage ->getBag ($ this -> attributeName )->get ($ name , $ default );
75
91
}
76
92
77
93
/**
78
94
* {@inheritdoc}
79
95
*/
80
96
public function set ($ name , $ value )
81
97
{
82
- $ this ->storage ->getBag (' attributes ' )->set ($ name , $ value );
98
+ $ this ->storage ->getBag ($ this -> attributeName )->set ($ name , $ value );
83
99
}
84
100
85
101
/**
86
102
* {@inheritdoc}
87
103
*/
88
104
public function all ()
89
105
{
90
- return $ this ->storage ->getBag (' attributes ' )->all ();
106
+ return $ this ->storage ->getBag ($ this -> attributeName )->all ();
91
107
}
92
108
93
109
/**
94
110
* {@inheritdoc}
95
111
*/
96
112
public function replace (array $ attributes )
97
113
{
98
- $ this ->storage ->getBag (' attributes ' )->replace ($ attributes );
114
+ $ this ->storage ->getBag ($ this -> attributeName )->replace ($ attributes );
99
115
}
100
116
101
117
/**
102
118
* {@inheritdoc}
103
119
*/
104
120
public function remove ($ name )
105
121
{
106
- return $ this ->storage ->getBag (' attributes ' )->remove ($ name );
122
+ return $ this ->storage ->getBag ($ this -> attributeName )->remove ($ name );
107
123
}
108
124
109
125
/**
110
126
* {@inheritdoc}
111
127
*/
112
128
public function clear ()
113
129
{
114
- $ this ->storage ->getBag (' attributes ' )->clear ();
130
+ $ this ->storage ->getBag ($ this -> attributeName )->clear ();
115
131
}
116
132
117
133
/**
@@ -201,7 +217,7 @@ public function getBag($name)
201
217
*/
202
218
public function getFlashBag ()
203
219
{
204
- return $ this ->getBag (' flashes ' );
220
+ return $ this ->getBag ($ this -> flashName );
205
221
}
206
222
207
223
// the following methods are kept for compatibility with Symfony 2.0 (they will be removed for Symfony 2.3)
0 commit comments