|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Chocofamily\LaravelEventSauce; |
|
4
|
|
|
|
|
5
|
|
|
use Chocofamily\LaravelEventSauce\Console\GenerateCommand; |
|
6
|
|
|
use Chocofamily\LaravelEventSauce\Console\MakeAggregateCommand; |
|
7
|
|
|
use Chocofamily\LaravelEventSauce\Console\MakeConsumerCommand; |
|
8
|
|
|
use EventSauce\EventSourcing\Serialization\ConstructingMessageSerializer; |
|
9
|
|
|
use EventSauce\EventSourcing\Serialization\MessageSerializer; |
|
10
|
|
|
use Illuminate\Support\ServiceProvider; |
|
11
|
|
|
|
|
12
|
|
|
final class EventSauceServiceProvider extends ServiceProvider |
|
13
|
|
|
{ |
|
14
|
|
|
public function boot() |
|
15
|
|
|
{ |
|
16
|
|
|
if ($this->app->runningInConsole()) { |
|
17
|
|
|
$this->publishes([ |
|
18
|
|
|
__DIR__.'/../config/eventsauce.php' => $this->app->configPath('eventsauce.php'), |
|
19
|
|
|
], ['eventsauce', 'eventsauce-config']); |
|
20
|
|
|
|
|
21
|
|
|
$this->publishes([ |
|
22
|
|
|
__DIR__.'/../database/migrations' => $this->app->databasePath('migrations'), |
|
23
|
|
|
], ['eventsauce', 'eventsauce-migrations']); |
|
24
|
|
|
} |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function register() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/eventsauce.php', 'eventsauce'); |
|
30
|
|
|
|
|
31
|
|
|
$this->app->bind(MessageSerializer::class, function () { |
|
32
|
|
|
return new ConstructingMessageSerializer(); |
|
33
|
|
|
}); |
|
34
|
|
|
|
|
35
|
|
|
$this->commands([ |
|
36
|
|
|
GenerateCommand::class, |
|
37
|
|
|
MakeAggregateCommand::class, |
|
38
|
|
|
MakeConsumerCommand::class, |
|
39
|
|
|
]); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function provides() |
|
43
|
|
|
{ |
|
44
|
|
|
return [ |
|
45
|
|
|
GenerateCommand::class, |
|
46
|
|
|
MakeAggregateCommand::class, |
|
47
|
|
|
MakeConsumerCommand::class, |
|
48
|
|
|
]; |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|