@@ -46,15 +46,12 @@ 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'),
56- ['ttl' => 600],
57- ]);
51+ $services
52+ ->set(RedisSessionHandler::class)
53+ ->arg('$redis', new Reference('Redis'))
54+ ->arg('$options', ['ttl' => 600]);
5855
5956
6057 .. _configuring-the-TTL-dynamically-at-runtime :
@@ -79,13 +76,13 @@ The callback will be called right before the session is written.
7976 Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler :
8077 arguments :
8178 - ' @Redis'
82- - { 'ttl': !closure [ '@my.ttl.handler'] }
79+ - { 'ttl': !closure '@my.ttl.handler' }
8380
8481 my.ttl.handler :
8582 class : Some\InvokableClass # some class with an __invoke() method
8683 arguments :
8784 # Inject whatever dependencies you need to be able to resolve a TTL for the current session
88- - @security
85+ - ' @security'
8986
9087 .. code-block :: xml
9188
@@ -94,26 +91,28 @@ The callback will be called right before the session is written.
9491 <service id =" Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler" >
9592 <argument type =" service" id =" Redis" />
9693 <argument type =" collection" >
97- <argument key =" ttl" >600</ argument >
94+ <argument key =" ttl" type = " closure " id = " my.ttl.handler " / >
9895 </argument >
9996 </service >
97+ <!-- some class with an __invoke() method -->
98+ <service id =" my.ttl.handler" class =" Some\InvokableClass" >
99+ <!-- Inject whatever dependencies you need to be able to resolve a TTL for the current session -->
100+ <argument type =" service" id =" security" />
101+ </service >
100102 </services >
101103
102104 .. code-block :: php
103105
104106 // config/services.php
105- use Symfony\Component\DependencyInjection\Reference;
106107 use Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler;
107108
108- $container
109- ->register(RedisSessionHandler::class)
110- ->setArguments([
111- new Reference('Redis'),
112- ['ttl' => new Reference('my.ttl.handler')],
113- ]);
114-
115- $container
109+ $services
110+ ->set(RedisSessionHandler::class)
111+ ->arg('$redis', new Reference('Redis'))
112+ ->arg('$options', ['ttl' => closure(service('my.ttl.handler'))]);
113+
114+ $services
116115 // some class with an __invoke() method
117- ->register ('my.ttl.handler', 'Some\InvokableClass')
116+ ->set ('my.ttl.handler', 'Some\InvokableClass')
118117 // Inject whatever dependencies you need to be able to resolve a TTL for the current session
119- ->addArgument(new Reference ('security'));
118+ ->arg('$security', service ('security'));
0 commit comments