Completed
Branch develop (3b926c)
by Bradley
02:54
created

NotifierServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 63
wmc 3
lcom 0
cbo 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A provides() 0 4 1
A boot() 0 14 1
A register() 0 17 1
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