|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace BinaryCube\CarrotMQ\Support\Laravel; |
|
6
|
|
|
|
|
7
|
|
|
use Psr\Log\LoggerInterface; |
|
8
|
|
|
use BinaryCube\CarrotMQ\CarrotMQ; |
|
9
|
|
|
use Illuminate\Foundation\Application; |
|
|
|
|
|
|
10
|
|
|
use BinaryCube\CarrotMQ\Support\Laravel\Console\Commands as Commands; |
|
11
|
|
|
|
|
12
|
|
|
use function is_array; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class CarrotMQServiceProvider |
|
16
|
|
|
*/ |
|
17
|
|
|
class CarrotMQServiceProvider extends \Illuminate\Support\ServiceProvider |
|
|
|
|
|
|
18
|
|
|
{ |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @return void |
|
22
|
|
|
*/ |
|
23
|
|
|
public function register() |
|
24
|
|
|
{ |
|
25
|
|
|
$this->publishConfig(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @return void |
|
30
|
|
|
*/ |
|
31
|
|
|
public function boot() |
|
32
|
|
|
{ |
|
33
|
|
|
$this->prepareApp(); |
|
34
|
|
|
$this->prepareCommands(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @return void |
|
39
|
|
|
*/ |
|
40
|
|
|
protected function publishConfig() |
|
41
|
|
|
{ |
|
42
|
|
|
$this |
|
43
|
|
|
->publishes( |
|
44
|
|
|
[ |
|
45
|
|
|
$this->getConfigFile() => config_path('carrot_mq.php'), |
|
|
|
|
|
|
46
|
|
|
] |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return void |
|
52
|
|
|
*/ |
|
53
|
|
|
protected function prepareApp() |
|
54
|
|
|
{ |
|
55
|
|
|
$config = config('carrot_mq', []); |
|
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
if (! is_array($config)) { |
|
58
|
|
|
throw new \RuntimeException( |
|
59
|
|
|
'Invalid configuration provided for CarrotMQ-Laravel!' |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
$this->app->bind('carrot.mq', function (Application $app) { |
|
|
|
|
|
|
64
|
|
|
return app(CarrotMQ::class); |
|
|
|
|
|
|
65
|
|
|
}); |
|
66
|
|
|
|
|
67
|
|
|
$this->app->singleton(CarrotMQ::class, function (Application $app, $arguments) use ($config) { |
|
|
|
|
|
|
68
|
|
|
$logger = $app->make(LoggerInterface::class); |
|
69
|
|
|
$carrot = new CarrotMQ($config, $logger); |
|
70
|
|
|
|
|
71
|
|
|
return $carrot; |
|
72
|
|
|
}); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return void |
|
77
|
|
|
*/ |
|
78
|
|
|
protected function prepareCommands() |
|
79
|
|
|
{ |
|
80
|
|
|
if (! $this->app->runningInConsole()) { |
|
81
|
|
|
return; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
$this->commands( |
|
85
|
|
|
[ |
|
86
|
|
|
Commands\ListCommand::class, |
|
87
|
|
|
Commands\SetupCommand::class, |
|
88
|
|
|
Commands\ConsumerCommand::class, |
|
89
|
|
|
Commands\DeleteAllCommand::class, |
|
90
|
|
|
Commands\PurgeCommand::class, |
|
91
|
|
|
Commands\PublisherCommand::class, |
|
92
|
|
|
] |
|
93
|
|
|
); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @return string |
|
98
|
|
|
*/ |
|
99
|
|
|
protected function getConfigFile() |
|
100
|
|
|
{ |
|
101
|
|
|
return (__DIR__ . '/config/carrot_mq.php'); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
} |
|
105
|
|
|
|
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