Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4a3a987

Browse filesBrowse files
committed
Update documentation for deprecated "session.storage" service
1 parent 1839389 commit 4a3a987
Copy full SHA for 4a3a987

File tree

3 files changed

+49
-26
lines changed
Filter options

3 files changed

+49
-26
lines changed

‎reference/configuration/framework.rst

Copy file name to clipboardExpand all lines: reference/configuration/framework.rst
+13-8Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ Configuration
269269
* `save_path`_
270270
* `sid_length`_
271271
* `sid_bits_per_character`_
272-
* `storage_id`_
272+
* `storage_factory_id`_
273273
* `use_cookies`_
274274

275275
* `test`_
@@ -1443,19 +1443,24 @@ errors.
14431443
session
14441444
~~~~~~~
14451445

1446-
storage_id
1447-
..........
1446+
storage_factory_id
1447+
..................
14481448

1449-
**type**: ``string`` **default**: ``'session.storage.native'``
1449+
**type**: ``string`` **default**: ``'session.storage.factory.native'``
14501450

1451-
The service ID used for storing the session. The ``session.storage`` service
1452-
alias will be set to this service. The class has to implement
1453-
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorageInterface`.
1451+
The service ID used for creatig the ``SessionStorageInterface`` that will store
1452+
the session. The ``session.storage.factory`` service alias will be set to this
1453+
service. The class has to implement
1454+
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorageFactoryInterface`.
14541455
To see a list of all available storages, run:
14551456

14561457
.. code-block:: terminal
14571458
1458-
$ php bin/console debug:container session.storage.
1459+
$ php bin/console debug:container session.storage.factory.
1460+
1461+
.. versionadded:: 5.3
1462+
1463+
The ``storage_factory_id`` option was introduced in Symfony 5.3.
14591464

14601465
.. _config-framework-session-handler-id:
14611466

‎session.rst

Copy file name to clipboardExpand all lines: session.rst
+31-13Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,33 +185,51 @@ your ``Session`` object with the default ``AttributeBag`` by the ``NamespacedAtt
185185
.. code-block:: yaml
186186
187187
# config/services.yaml
188-
session_listener:
188+
session.factory:
189189
autoconfigure: true
190-
class: App\EventListener\SessionListener
190+
class: App\Session\SessionFactory
191191
arguments:
192-
- !service_locator
193-
logger: '@?logger'
194-
session_collector: '@?data_collector.request.session_collector'
195-
session_storage: '@session.storage'
196-
session_attributes: '@session.namespacedattributebag'
197-
- '%kernel.debug%'
192+
- '@request_stack'
193+
- '@session.storage.factory'
194+
- ['@session_listener', 'onSessionUsage']
195+
- '@session.namespacedattributebag'
198196
199197
session.namespacedattributebag:
200198
class: Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag
201199
202200
.. code-block:: php
203201
204-
namespace App\EventListener;
202+
namespace App\Session;
205203
204+
use Symfony\Component\HttpFoundation\RequestStack;
205+
use Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag;
206206
use Symfony\Component\HttpFoundation\Session\Session;
207207
use Symfony\Component\HttpFoundation\Session\SessionInterface;
208-
use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener;
208+
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageFactoryInterface;
209209
210-
class SessionListener extends AbstractSessionListener
210+
class SessionFactory
211211
{
212-
protected function getSession(): ?SessionInterface
212+
private $requestStack;
213+
private $storageFactory;
214+
private $usageReporter;
215+
private $sessionAttributes;
216+
217+
public function __construct(RequestStack $requestStack, SessionStorageFactoryInterface $storageFactory, callable $usageReporter, NamespacedAttributeBag $sessionAttributes)
218+
{
219+
$this->requestStack = $requestStack;
220+
$this->storageFactory = $storageFactory;
221+
$this->usageReporter = $usageReporter;
222+
$this->sessionAttributes = $sessionAttributes;
223+
}
224+
225+
public function createSession(): SessionInterface
213226
{
214-
return new Session($this->container->get('session_storage'), $this->container->get('session_attributes'));
227+
return new Session(
228+
$this->storageFactory->createStorage($this->requestStack->getMasterRequest()),
229+
$this->sessionAttributes,
230+
null,
231+
$this->usageReporter
232+
);
215233
}
216234
}
217235

‎session/php_bridge.rst

Copy file name to clipboardExpand all lines: session/php_bridge.rst
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ for the ``handler_id``:
1818
# config/packages/framework.yaml
1919
framework:
2020
session:
21-
storage_id: session.storage.php_bridge
21+
storage_factory_id: session.storage.factory.php_bridge
2222
handler_id: ~
2323
2424
.. code-block:: xml
@@ -32,7 +32,7 @@ for the ``handler_id``:
3232
https://symfony.com/schema/dic/services/services-1.0.xsd">
3333
3434
<framework:config>
35-
<framework:session storage-id="session.storage.php_bridge"
35+
<framework:session storage-factory-id="session.storage.factory.php_bridge"
3636
handler-id="null"
3737
/>
3838
</framework:config>
@@ -43,7 +43,7 @@ for the ``handler_id``:
4343
// config/packages/framework.php
4444
$container->loadFromExtension('framework', [
4545
'session' => [
46-
'storage_id' => 'session.storage.php_bridge',
46+
'storage_factory_id' => 'session.storage.factory.php_bridge',
4747
'handler_id' => null,
4848
],
4949
]);
@@ -60,7 +60,7 @@ the example below:
6060
# config/packages/framework.yaml
6161
framework:
6262
session:
63-
storage_id: session.storage.php_bridge
63+
storage_factory_id: session.storage.factory.php_bridge
6464
handler_id: session.handler.native_file
6565
6666
.. code-block:: xml
@@ -85,7 +85,7 @@ the example below:
8585
// config/packages/framework.php
8686
$container->loadFromExtension('framework', [
8787
'session' => [
88-
'storage_id' => 'session.storage.php_bridge',
88+
'storage_factory_id' => 'session.storage.factory.php_bridge',
8989
'handler_id' => 'session.storage.native_file',
9090
],
9191
]);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.