Skip to content

Commit 1f503db

Browse files
committed
Apply feedback
1 parent cfeaa0c commit 1f503db

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

session/configuring_ttl.rst

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,14 @@ You need to pass the TTL in the options array of the session handler you are usi
4646
.. code-block:: php
4747
4848
// config/services.php
49-
use Symfony\Component\DependencyInjection\Reference;
5049
use Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler;
5150
52-
$container
53-
->register(RedisSessionHandler::class)
54-
->setArguments([
55-
new Reference('Redis'),
51+
$services
52+
->set(RedisSessionHandler::class)
53+
->args([
54+
service('Redis'),
5655
['ttl' => 600],
57-
]);
58-
56+
])
5957
6058
.. _configuring-the-TTL-dynamically-at-runtime:
6159

@@ -79,13 +77,13 @@ The callback will be called right before the session is written.
7977
Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler:
8078
arguments:
8179
- '@Redis'
82-
- { 'ttl': !closure ['@my.ttl.handler'] }
80+
- { 'ttl': !closure '@my.ttl.handler' }
8381
8482
my.ttl.handler:
8583
class: Some\InvokableClass # some class with an __invoke() method
8684
arguments:
8785
# Inject whatever dependencies you need to be able to resolve a TTL for the current session
88-
- @security
86+
- '@security'
8987
9088
.. code-block:: xml
9189
@@ -94,26 +92,30 @@ The callback will be called right before the session is written.
9492
<service id="Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler">
9593
<argument type="service" id="Redis"/>
9694
<argument type="collection">
97-
<argument key="ttl">600</argument>
95+
<argument key="ttl" type="closure" id="my.ttl.handler"/>
9896
</argument>
9997
</service>
98+
<!-- some class with an __invoke() method -->
99+
<service id="my.ttl.handler" class="Some\InvokableClass">
100+
<!-- Inject whatever dependencies you need to be able to resolve a TTL for the current session -->
101+
<argument type="service" id="security"/>
102+
</service>
100103
</services>
101104
102105
.. code-block:: php
103106
104107
// config/services.php
105-
use Symfony\Component\DependencyInjection\Reference;
106108
use Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler;
107109
108-
$container
109-
->register(RedisSessionHandler::class)
110-
->setArguments([
111-
new Reference('Redis'),
112-
['ttl' => new Reference('my.ttl.handler')],
113-
]);
114-
115-
$container
110+
$services
111+
->set(RedisSessionHandler::class)
112+
->args([
113+
service('Redis'),
114+
['ttl' => closure(service('my.ttl.handler'))],
115+
])
116+
117+
$services
116118
// some class with an __invoke() method
117-
->register('my.ttl.handler', 'Some\InvokableClass')
119+
->set('my.ttl.handler', 'Some\InvokableClass')
118120
// Inject whatever dependencies you need to be able to resolve a TTL for the current session
119-
->addArgument(new Reference('security'));
121+
->args([service('security')]);

0 commit comments

Comments
 (0)