1515 */
1616final class SessionServiceProvider extends ServiceProvider
1717{
18+ public const DRIVER_NAME = 'tarantool ' ;
19+
1820 public function register (): void
1921 {
2022 $ this ->mergeConfigFrom (
@@ -34,20 +36,22 @@ public function boot(): void
3436 ], 'tarantool-session-config ' );
3537 }
3638
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 ' ];
3942
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+ ]);
4548
46- return new TarantoolSessionHandler ($ client , $ options ['space ' ]);
47- });
49+ return new TarantoolSessionHandler ($ client , $ options ['space ' ]);
50+ });
4851
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+ }
5256 }
5357}
0 commit comments