1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Honeybadger\HoneybadgerLaravel; |
4
|
|
|
|
5
|
|
|
use Honeybadger\Honeybadger; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
use Illuminate\Console\Scheduling\Event; |
8
|
|
|
use Honeybadger\HoneybadgerLaravel\Commands\HoneybadgerTestCommand; |
9
|
|
|
use Honeybadger\HoneybadgerLaravel\Commands\HoneybadgerCheckinCommand; |
10
|
|
|
|
11
|
|
|
class HoneybadgerServiceProvider extends ServiceProvider |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Bootstrap the application services. |
15
|
|
|
*/ |
16
|
|
|
public function boot() |
17
|
|
|
{ |
18
|
|
|
if ($this->app->runningInConsole()) { |
19
|
|
|
$this->bindCommands(); |
20
|
|
|
$this->registerCommands(); |
21
|
|
|
|
22
|
|
|
$this->publishes([ |
23
|
|
|
__DIR__.'/../config/honeybadger.php' => base_path('config/honeybadger.php'), |
24
|
|
|
], 'config'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
$this->registerMacros(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Register the application services. |
32
|
|
|
*/ |
33
|
|
|
public function register() |
34
|
|
|
{ |
35
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/honeybadger.php', 'honeybadger'); |
36
|
|
|
|
37
|
|
|
$this->app->singleton(Honeybadger::class, function ($app) { |
38
|
|
|
return (new HoneybadgerLaravel)->make($app['config']['honeybadger']); |
39
|
|
|
}); |
40
|
|
|
|
41
|
|
|
$this->app->alias(Honeybadger::class, 'honeybadger'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return void |
46
|
|
|
*/ |
47
|
|
|
private function registerCommands() |
48
|
|
|
{ |
49
|
|
|
$this->commands([ |
50
|
|
|
'command.honeybadger:test', |
51
|
|
|
'command.honeybadger:checkin', |
52
|
|
|
]); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return void |
57
|
|
|
*/ |
58
|
|
|
private function bindCommands() |
59
|
|
|
{ |
60
|
|
|
$this->app->bind( |
61
|
|
|
'command.honeybadger:test', |
62
|
|
|
HoneybadgerTestCommand::class |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
$this->app->bind( |
66
|
|
|
'command.honeybadger:checkin', |
67
|
|
|
HoneybadgerCheckinCommand::class |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return void |
73
|
|
|
*/ |
74
|
|
|
private function registerMacros() |
75
|
|
|
{ |
76
|
|
|
Event::macro('thenPingHoneybadger', function ($id) { |
77
|
|
|
return $this->then(function () use ($id) { |
78
|
|
|
app(Honeybadger::class)->checkin($id); |
79
|
|
|
}); |
80
|
|
|
}); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|