1
+ <?php
2
+
3
+ namespace LithiumDev \ExceptionMailer ;
4
+
5
+
6
+ use Illuminate \Support \ServiceProvider ;
7
+
8
+ class ExceptionMailerServiceProvider extends ServiceProvider {
9
+ /**
10
+ * Indicates if loading of the provider is deferred.
11
+ *
12
+ * @var bool
13
+ */
14
+ protected $ defer = false ;
15
+
16
+ /**
17
+ * Bootstrap the application events.
18
+ *
19
+ * @return void
20
+ */
21
+ public function boot ()
22
+ {
23
+ $ this ->publishes ([
24
+ __DIR__ . '/../../config/config.php ' => config_path ('laravel-exception-mailer/config.php ' ),
25
+ __DIR__ . '/../../views ' => base_path ('resources/views/vendor/laravel-exception-mailer ' ),
26
+ ]);
27
+ $ this ->loadViewsFrom (__DIR__ . '/../../views ' , 'laravel-exception-mailer ' );
28
+
29
+ $ this ->app ->singleton ('Illuminate\Contracts\Debug\ExceptionHandler ' , 'LithiumDev\ExceptionMailer\ExceptionHandler ' );
30
+ }
31
+
32
+ /**
33
+ * Register the service provider.
34
+ *
35
+ * @return void
36
+ */
37
+ public function register ()
38
+ {
39
+ $ this ->mergeConfigFrom (
40
+ __DIR__ . '/../../config/config.php ' , 'laravel-exception-mailer.config '
41
+ );
42
+
43
+ $ this ->app ['ExceptionMailer ' ] = $ this ->app ->share (function ($ app )
44
+ {
45
+ $ config = $ app ['config ' ]['laravel-exception-mailer ' ]['config ' ];
46
+ $ eMailer = new ExceptionMailer ($ config );
47
+
48
+ if (in_array ($ app ->environment (), $ config ['notify_environment ' ]))
49
+ {
50
+ $ eMailer ->setEnvironment ($ app ->environment ());
51
+ }
52
+
53
+ return $ eMailer ;
54
+ });
55
+ $ this ->app ->singleton ('ExceptionMailer ' ,
56
+ function ($ app )
57
+ {
58
+ $ config = $ app ['config ' ]['laravel-exception-mailer ' ]['config ' ];
59
+
60
+ $ eMailer = new ExceptionMailer ($ config );
61
+
62
+ if (in_array ($ app ->environment (), $ config ['notify_environment ' ]))
63
+ {
64
+ $ eMailer ->setEnvironment ($ app ->environment ());
65
+ }
66
+
67
+ return $ eMailer ;
68
+ });
69
+ // Shortcut so developers don't need to add an Alias in app/config/app.php
70
+ $ this ->app ->booting (function ()
71
+ {
72
+ $ loader = \Illuminate \Foundation \AliasLoader::getInstance ();
73
+ $ loader ->alias ('ExceptionMailer ' , 'LithiumDev\ExceptionMailer\Facades\ExceptionMailerFacade ' );
74
+ });
75
+ }
76
+
77
+ /**
78
+ * Get the services provided by the provider.
79
+ *
80
+ * @return array
81
+ */
82
+ public function provides ()
83
+ {
84
+ return array ("ExceptionMailer " );
85
+ }
86
+ }
0 commit comments