|
1
|
|
|
<?php namespace Cornford\Notifier\Providers; |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
use Cornford\Notifier\Listeners\AfterListener; |
|
5
|
|
|
use Cornford\Notifier\Listeners\BeforeListener; |
|
6
|
|
|
use Cornford\Notifier\Notifier; |
|
7
|
|
|
use Illuminate\Support\ServiceProvider; |
|
8
|
|
|
|
|
9
|
|
|
class NotifierServiceProvider extends ServiceProvider { |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Indicates if loading of the provider is deferred. |
|
13
|
|
|
* |
|
14
|
|
|
* @var boolean |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $defer = false; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Bootstrap the application events. |
|
20
|
|
|
* |
|
21
|
|
|
* @return void |
|
22
|
|
|
*/ |
|
23
|
|
|
public function boot(\Illuminate\Routing\Router $router) |
|
24
|
|
|
{ |
|
25
|
|
|
$this->publishes( |
|
26
|
|
|
[ |
|
27
|
|
|
__DIR__ . '/../../../config/config.php' => config_path('notifier.php'), |
|
28
|
|
|
__DIR__ . '/../../../../public' => public_path('packages/cornford/notifier') |
|
29
|
|
|
], |
|
30
|
|
|
'notifier' |
|
31
|
|
|
); |
|
32
|
|
|
|
|
33
|
|
|
$this->loadViewsFrom(__DIR__ . '/../../../views', 'notifier'); |
|
34
|
|
|
|
|
35
|
|
|
include __DIR__ . '/../../../routes.php'; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Register the service provider. |
|
40
|
|
|
* |
|
41
|
|
|
* @return void |
|
42
|
|
|
*/ |
|
43
|
|
|
public function register() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->mergeConfigFrom(__DIR__ . '/../../../config/config.php', 'notifier'); |
|
46
|
|
|
|
|
47
|
|
|
$this->app['router']->middleware('NotifierBeforeListener', 'Cornford\\Notifier\\Listeners\\BeforeListener'); |
|
48
|
|
|
$this->app['router']->middleware('NotifierAfterListener', 'Cornford\\Notifier\\Listeners\\AfterListener'); |
|
49
|
|
|
|
|
50
|
|
|
$this->app['router']->before(BeforeListener::class); |
|
51
|
|
|
$this->app['router']->after(AfterListener::class); |
|
52
|
|
|
|
|
53
|
|
|
$this->app['notifier'] = $this->app->share(function($app) |
|
54
|
|
|
{ |
|
55
|
|
|
$config = $app['config']->get('notifier'); |
|
56
|
|
|
|
|
57
|
|
|
return new Notifier($this->app->view, $this->app->{'session.store'}, $config); |
|
58
|
|
|
}); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Get the services provided by the provider. |
|
63
|
|
|
* |
|
64
|
|
|
* @return string[] |
|
65
|
|
|
*/ |
|
66
|
|
|
public function provides() |
|
67
|
|
|
{ |
|
68
|
|
|
return ['notifier']; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|