1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sebdesign\SM; |
4
|
|
|
|
5
|
|
|
use Illuminate\Foundation\Application as LaravelApplication; |
6
|
|
|
use Illuminate\Support\ServiceProvider as BaseServiceProvider; |
7
|
|
|
use Laravel\Lumen\Application as LumenApplication; |
|
|
|
|
8
|
|
|
use Sebdesign\SM\Callback\ContainerAwareCallback; |
9
|
|
|
use Sebdesign\SM\Callback\ContainerAwareCallbackFactory; |
10
|
|
|
use Sebdesign\SM\Commands\Debug; |
11
|
|
|
use Sebdesign\SM\Commands\Visualize; |
12
|
|
|
use Sebdesign\SM\Event\Dispatcher; |
13
|
|
|
use Sebdesign\SM\Factory\Factory; |
14
|
|
|
use SM\Callback\CallbackFactoryInterface; |
15
|
|
|
use SM\Callback\CascadeTransitionCallback; |
16
|
|
|
use SM\Factory\FactoryInterface; |
17
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
18
|
|
|
|
19
|
|
|
class ServiceProvider extends BaseServiceProvider |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Indicates if loading of the provider is deferred. |
23
|
|
|
* |
24
|
|
|
* @var bool |
25
|
|
|
*/ |
26
|
|
|
protected $defer = false; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Bootstrap the application services. |
30
|
|
|
*/ |
31
|
171 |
|
public function boot() |
32
|
|
|
{ |
33
|
171 |
|
if ($this->app->runningInConsole()) { |
34
|
171 |
|
if ($this->app instanceof LaravelApplication) { |
35
|
171 |
|
$this->publishes([ |
36
|
171 |
|
__DIR__.'/../config/state-machine.php' => config_path('state-machine.php'), |
37
|
171 |
|
], 'config'); |
38
|
|
|
} elseif ($this->app instanceof LumenApplication) { |
39
|
|
|
$this->app->configure('state-machine'); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
} |
42
|
57 |
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Register the application services. |
46
|
|
|
*/ |
47
|
171 |
|
public function register() |
48
|
|
|
{ |
49
|
171 |
|
$this->registerCallbackFactory(); |
50
|
171 |
|
$this->registerEventDispatcher(); |
51
|
171 |
|
$this->registerFactory(); |
52
|
171 |
|
$this->registerCascadeTransitionCallback(); |
53
|
171 |
|
$this->registerCommands(); |
54
|
57 |
|
} |
55
|
|
|
|
56
|
171 |
|
protected function registerCallbackFactory() |
57
|
|
|
{ |
58
|
114 |
|
$this->app->bind('sm.callback.factory', function ($app) { |
59
|
75 |
|
return new ContainerAwareCallbackFactory(ContainerAwareCallback::class, $app); |
60
|
171 |
|
}); |
61
|
|
|
|
62
|
171 |
|
$this->app->alias('sm.callback.factory', CallbackFactoryInterface::class); |
63
|
57 |
|
} |
64
|
|
|
|
65
|
171 |
|
protected function registerEventDispatcher() |
66
|
|
|
{ |
67
|
114 |
|
$this->app->bind('sm.event.dispatcher', function ($app) { |
68
|
99 |
|
return new Dispatcher($app->make('events')); |
69
|
171 |
|
}); |
70
|
|
|
|
71
|
171 |
|
$this->app->alias('sm.event.dispatcher', EventDispatcherInterface::class); |
72
|
57 |
|
} |
73
|
|
|
|
74
|
171 |
|
protected function registerFactory() |
75
|
|
|
{ |
76
|
114 |
|
$this->app->singleton('sm.factory', function ($app) { |
77
|
27 |
|
return new Factory( |
78
|
27 |
|
$app->make('config')->get('state-machine', []), |
79
|
27 |
|
$app->make('sm.event.dispatcher'), |
80
|
27 |
|
$app->make('sm.callback.factory') |
81
|
18 |
|
); |
82
|
171 |
|
}); |
83
|
|
|
|
84
|
171 |
|
$this->app->alias('sm.factory', FactoryInterface::class); |
85
|
57 |
|
} |
86
|
|
|
|
87
|
171 |
|
protected function registerCascadeTransitionCallback() |
88
|
|
|
{ |
89
|
114 |
|
$this->app->bind(CascadeTransitionCallback::class, function ($app) { |
90
|
3 |
|
return new CascadeTransitionCallback($app->make('sm.factory')); |
91
|
171 |
|
}); |
92
|
57 |
|
} |
93
|
|
|
|
94
|
171 |
|
protected function registerCommands() |
95
|
|
|
{ |
96
|
114 |
|
$this->app->bind(Debug::class, function ($app) { |
97
|
18 |
|
return new Debug($app->make('config')->get('state-machine', [])); |
98
|
171 |
|
}); |
99
|
|
|
|
100
|
114 |
|
$this->app->bind(Visualize::class, function ($app) { |
101
|
15 |
|
return new Visualize($app->make('config')->get('state-machine', [])); |
102
|
171 |
|
}); |
103
|
|
|
|
104
|
171 |
|
$this->commands([ |
105
|
171 |
|
Debug::class, |
106
|
114 |
|
Visualize::class, |
107
|
114 |
|
]); |
108
|
57 |
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Get the services provided by the provider. |
112
|
|
|
* |
113
|
|
|
* @return array |
114
|
|
|
*/ |
115
|
6 |
|
public function provides() |
116
|
|
|
{ |
117
|
4 |
|
return [ |
118
|
6 |
|
'sm.callback.factory', |
119
|
4 |
|
'sm.event.dispatcher', |
120
|
4 |
|
'sm.factory', |
121
|
4 |
|
Debug::class, |
122
|
4 |
|
]; |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths