15
15
*/
16
16
final class SessionServiceProvider extends ServiceProvider
17
17
{
18
+ public const DRIVER_NAME = 'tarantool ' ;
19
+
18
20
public function register (): void
19
21
{
20
22
$ this ->mergeConfigFrom (
@@ -34,20 +36,22 @@ public function boot(): void
34
36
], 'tarantool-session-config ' );
35
37
}
36
38
37
- $ this ->app ->singleton (TarantoolSessionHandler::class, static function (Application $ app ) {
38
- $ options = $ app ['config ' ]['tarantool-session ' ];
39
+ if ($ this ->app ['config ' ]['session ' ]['driver ' ] === self ::DRIVER_NAME ) {
40
+ $ this ->app ->singleton (TarantoolSessionHandler::class, static function (Application $ app ) {
41
+ $ options = $ app ['config ' ]['tarantool-session ' ];
39
42
40
- $ client = Client::fromOptions ([
41
- 'uri ' => $ options ['host ' ],
42
- 'username ' => $ options ['user ' ],
43
- 'password ' => $ options ['password ' ],
44
- ]);
43
+ $ client = Client::fromOptions ([
44
+ 'uri ' => $ options ['host ' ],
45
+ 'username ' => $ options ['user ' ],
46
+ 'password ' => $ options ['password ' ],
47
+ ]);
45
48
46
- return new TarantoolSessionHandler ($ client , $ options ['space ' ]);
47
- });
49
+ return new TarantoolSessionHandler ($ client , $ options ['space ' ]);
50
+ });
48
51
49
- Session::extend ('tarantool ' , static function (Application $ app ) {
50
- return $ app ->make (TarantoolSessionHandler::class);
51
- });
52
+ Session::extend (self ::DRIVER_NAME , static function (Application $ app ) {
53
+ return $ app ->make (TarantoolSessionHandler::class);
54
+ });
55
+ }
52
56
}
53
57
}
0 commit comments