1
|
<?php
|
2
|
|
3
|
namespace Illuminate\Session;
|
4
|
|
5
|
use Illuminate\Support\ServiceProvider;
|
6
|
|
7
|
class SessionServiceProvider extends ServiceProvider
|
8
|
{
|
9
|
/**
|
10
|
* Register the service provider.
|
11
|
*
|
12
|
* @return void
|
13
|
*/
|
14
|
public function register()
|
15
|
{
|
16
|
$this->registerSessionManager();
|
17
|
|
18
|
$this->registerSessionDriver();
|
19
|
|
20
|
$this->app->singleton('Illuminate\Session\Middleware\StartSession');
|
21
|
}
|
22
|
|
23
|
/**
|
24
|
* Register the session manager instance.
|
25
|
*
|
26
|
* @return void
|
27
|
*/
|
28
|
protected function registerSessionManager()
|
29
|
{
|
30
|
$this->app->singleton('session', function ($app) {
|
31
|
return new SessionManager($app);
|
32
|
});
|
33
|
}
|
34
|
|
35
|
/**
|
36
|
* Register the session driver instance.
|
37
|
*
|
38
|
* @return void
|
39
|
*/
|
40
|
protected function registerSessionDriver()
|
41
|
{
|
42
|
$this->app->singleton('session.store', function ($app) {
|
43
|
// First, we will create the session manager which is responsible for the
|
44
|
// creation of the various session drivers when they are needed by the
|
45
|
// application instance, and will resolve them on a lazy load basis.
|
46
|
$manager = $app['session'];
|
47
|
|
48
|
return $manager->driver();
|
49
|
});
|
50
|
}
|
51
|
}
|