@@ -181,6 +181,33 @@ and remember me login settings or other user based state information.
181
181
:class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ NamespacedAttributeBag `
182
182
This implementation allows for attributes to be stored in a structured namespace.
183
183
184
+ :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface `
185
+ has a simple API
186
+
187
+ :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::set `
188
+ Sets an attribute by key.
189
+
190
+ :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::get `
191
+ Gets an attribute by key.
192
+
193
+ :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::all `
194
+ Gets all attributes as an array of key => value.
195
+
196
+ :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::has `
197
+ Returns true if the attribute exists.
198
+
199
+ :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::replace `
200
+ Sets multiple attributes at once: takes a keyed array and sets each key => value pair.
201
+
202
+ :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::remove `
203
+ Deletes an attribute by key.
204
+
205
+ :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::clear `
206
+ Clear the bag.
207
+
208
+ Namespaced Attributes
209
+ .....................
210
+
184
211
Any plain key-value storage system is limited in the extent to which
185
212
complex data can be stored since each key must be unique. You can achieve
186
213
namespacing by introducing a naming convention to the keys so different parts of
@@ -211,29 +238,19 @@ structure like this using a namespace character (defaults to ``/``)::
211
238
212
239
This way you can easily access a key within the stored array directly and easily.
213
240
214
- :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface `
215
- has a simple API
216
-
217
- :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::set `
218
- Sets an attribute by key.
219
-
220
- :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::get `
221
- Gets an attribute by key.
222
-
223
- :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::all `
224
- Gets all attributes as an array of key => value.
225
-
226
- :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::has `
227
- Returns true if the attribute exists.
228
-
229
- :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::replace `
230
- Sets multiple attributes at once: takes a keyed array and sets each key => value pair.
231
-
232
- :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::remove `
233
- Deletes an attribute by key.
234
-
235
- :method: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBagInterface::clear `
236
- Clear the bag.
241
+ To activate Namespaced Attributes, add this to your `services.yml `::
242
+
243
+ # app/config/services.yml
244
+
245
+ services:
246
+ session:
247
+ class: Symfony\Component\HttpFoundation\Session\Session
248
+ arguments:
249
+ - @session.storage
250
+ - @your.session.attribute_bag #service id is defined below
251
+ - @session.flash_bag
252
+ your.session.attribute_bag:
253
+ class: Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag
237
254
238
255
Flash Messages
239
256
~~~~~~~~~~~~~~
0 commit comments