1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tylercd100\Notify\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Tylercd100\Notify\Drivers\FromConfig; |
7
|
|
|
use Tylercd100\Notify\Drivers\HipChat; |
8
|
|
|
use Tylercd100\Notify\Drivers\Mail; |
9
|
|
|
use Tylercd100\Notify\Drivers\Pushover; |
10
|
|
|
use Tylercd100\Notify\Drivers\Flowdock; |
11
|
|
|
use Tylercd100\Notify\Drivers\FleepHook; |
12
|
|
|
use Tylercd100\Notify\Drivers\Slack; |
13
|
|
|
use Tylercd100\Notify\Drivers\Plivo; |
14
|
|
|
use Tylercd100\Notify\Drivers\Twilio; |
15
|
|
|
|
16
|
|
|
class NotifyServiceProvider extends ServiceProvider |
17
|
|
|
{ |
18
|
33 |
|
public function register() { |
19
|
33 |
|
$this->mergeConfigFrom(__DIR__ . '/../../config/notify.php', 'notify'); |
20
|
|
|
|
21
|
|
|
$registerMap = [ |
22
|
33 |
|
'notify' => FromConfig::class, |
23
|
33 |
|
'notify-pushover' => Pushover::class, |
24
|
33 |
|
'notify-slack' => Slack::class, |
25
|
33 |
|
'notify-hipchat' => HipChat::class, |
26
|
33 |
|
'notify-mail' => Mail::class, |
27
|
33 |
|
'notify-twilio' => Twilio::class, |
28
|
33 |
|
'notify-plivo' => Plivo::class, |
29
|
33 |
|
'notify-fleephook' => FleepHook::class, |
30
|
33 |
|
'notify-flowdock' => Flowdock::class, |
31
|
33 |
|
]; |
32
|
|
|
|
33
|
33 |
|
$this->registerSingletonsFromMap($registerMap); |
34
|
33 |
|
} |
35
|
|
|
|
36
|
33 |
|
public function boot() |
37
|
|
|
{ |
38
|
33 |
|
$this->publishes([ |
39
|
33 |
|
__DIR__ . '/../../config/notify.php' => base_path('config/notify.php'), |
40
|
33 |
|
]); |
41
|
33 |
|
} |
42
|
|
|
|
43
|
33 |
|
private function registerSingletonsFromMap($map){ |
44
|
33 |
|
foreach ($map as $key => $class) { |
45
|
33 |
|
$this->app->singleton($key, function() use ($class){ |
46
|
30 |
|
return new $class; |
47
|
33 |
|
}); |
48
|
33 |
|
} |
49
|
|
|
} |
50
|
|
|
} |