1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Joselfonseca\LaravelTactician\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Joselfonseca\LaravelTactician\Commands\MakeTacticianCommand; |
7
|
|
|
use Joselfonseca\LaravelTactician\Commands\MakeTacticianCommandCommand; |
8
|
|
|
use Joselfonseca\LaravelTactician\Commands\MakeTacticianHandlerCommand; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class LaravelTacticianServiceProvider |
12
|
|
|
* |
13
|
|
|
* @package Joselfonseca\LaravelTactician\Providers |
14
|
|
|
*/ |
15
|
|
|
class LaravelTacticianServiceProvider extends ServiceProvider |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Do the bindings so any implementation can be swapped |
20
|
|
|
* |
21
|
|
|
* @return void |
22
|
|
|
*/ |
23
|
|
|
public function register() |
24
|
|
|
{ |
25
|
|
|
$this->registerConfig(); |
26
|
|
|
$this->app->bind('Joselfonseca\LaravelTactician\Locator\LocatorInterface', config('laravel-tactician.locator')); |
27
|
|
|
|
28
|
|
|
$this->app->bind('League\Tactician\Handler\MethodNameInflector\MethodNameInflector', config('laravel-tactician.inflector')); |
29
|
|
|
$this->app->bind('Joselfonseca\LaravelTactician\Handler\MethodNameInflectorUndoable', config('laravel-tactician.inflector-undoable')); |
30
|
|
|
|
31
|
|
|
$this->app->bind('League\Tactician\Handler\CommandNameExtractor\CommandNameExtractor', config('laravel-tactician.extractor')); |
32
|
|
|
$this->app->bind('Joselfonseca\LaravelTactician\Handler\CommandNameExtractorUndoable', config('laravel-tactician.extractor-undoable')); |
33
|
|
|
|
34
|
|
|
$this->app->bind('Joselfonseca\LaravelTactician\CommandBusInterface', config('laravel-tactician.bus')); |
35
|
|
|
$this->app->bind('Joselfonseca\LaravelTactician\CommandBusUndoableInterface', config('laravel-tactician.bus-undoable')); |
36
|
|
|
|
37
|
|
|
// Register Command Generator |
38
|
|
|
$this->app->singleton( |
39
|
|
|
'laravel-tactician.make.command', function ($app) { |
40
|
|
|
return new MakeTacticianCommandCommand($app['files']); |
41
|
|
|
} |
42
|
|
|
); |
43
|
|
|
$this->commands('laravel-tactician.make.command'); |
44
|
|
|
|
45
|
|
|
// Register Handler Generator |
46
|
|
|
$this->app->singleton( |
47
|
|
|
'laravel-tactician.make.handler', function ($app) { |
48
|
|
|
return new MakeTacticianHandlerCommand($app['files']); |
49
|
|
|
} |
50
|
|
|
); |
51
|
|
|
$this->commands('laravel-tactician.make.handler'); |
52
|
|
|
|
53
|
|
|
// Register Comman+Handler Generator Command |
54
|
|
|
$this->app->singleton( |
55
|
|
|
'laravel-tactician.make.tactician', function () { |
56
|
|
|
return new MakeTacticianCommand(); |
57
|
|
|
} |
58
|
|
|
); |
59
|
|
|
$this->commands('laravel-tactician.make.tactician'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Register config. |
64
|
|
|
* |
65
|
|
|
* @return void |
66
|
|
|
*/ |
67
|
|
|
protected function registerConfig() |
68
|
|
|
{ |
69
|
|
|
$this->publishes( |
70
|
|
|
[ |
71
|
|
|
__DIR__.'/../../config/config.php' => config_path('laravel-tactician.php'), |
72
|
|
|
] |
73
|
|
|
); |
74
|
|
|
$this->mergeConfigFrom( |
75
|
|
|
__DIR__.'/../../config/config.php', |
76
|
|
|
'laravel-tactician' |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|