|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Zing\LaravelSms; |
|
6
|
|
|
|
|
7
|
|
|
use Illuminate\Contracts\Container\Container; |
|
8
|
|
|
use Illuminate\Foundation\Application as Laravel; |
|
9
|
|
|
use Illuminate\Notifications\ChannelManager; |
|
10
|
|
|
use Illuminate\Support\Facades\Notification; |
|
11
|
|
|
use Illuminate\Support\ServiceProvider; |
|
12
|
|
|
use Laravel\Lumen\Application as Lumen; |
|
|
|
|
|
|
13
|
|
|
use Zing\LaravelSms\Channels\SmsChannel; |
|
14
|
|
|
use Zing\LaravelSms\Commands\SmsSwitchConnectionCommand; |
|
15
|
|
|
use Zing\LaravelSms\Facades\Sms; |
|
16
|
|
|
|
|
17
|
|
|
class SmsServiceProvider extends ServiceProvider |
|
18
|
|
|
{ |
|
19
|
|
|
private const SMS = 'sms'; |
|
20
|
|
|
|
|
21
|
50 |
|
public function boot(): void |
|
22
|
|
|
{ |
|
23
|
50 |
|
if (! $this->app->runningInConsole()) { |
|
24
|
|
|
return; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
50 |
|
if (! $this->app instanceof Laravel) { |
|
28
|
|
|
return; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
50 |
|
$this->publishes( |
|
32
|
|
|
[ |
|
33
|
50 |
|
$this->getConfigPath() => config_path('sms.php'), |
|
34
|
|
|
], |
|
35
|
50 |
|
'config' |
|
36
|
|
|
); |
|
37
|
50 |
|
} |
|
38
|
|
|
|
|
39
|
50 |
|
public function register(): void |
|
40
|
|
|
{ |
|
41
|
50 |
|
$this->registerConfig(); |
|
42
|
50 |
|
Notification::resolved( |
|
43
|
50 |
|
function (ChannelManager $service): void { |
|
44
|
11 |
|
$service->extend( |
|
45
|
11 |
|
self::SMS, |
|
46
|
11 |
|
function (Container $app) { |
|
47
|
2 |
|
return $app->make(SmsChannel::class); |
|
48
|
11 |
|
} |
|
49
|
|
|
); |
|
50
|
50 |
|
} |
|
51
|
|
|
); |
|
52
|
50 |
|
$this->app->singleton( |
|
53
|
50 |
|
self::SMS, |
|
54
|
50 |
|
function (Container $app) { |
|
55
|
12 |
|
return $app->make(SmsManager::class); |
|
56
|
50 |
|
} |
|
57
|
|
|
); |
|
58
|
50 |
|
$this->app->alias(self::SMS, Sms::class); |
|
59
|
50 |
|
$this->registerCommands(); |
|
60
|
50 |
|
} |
|
61
|
|
|
|
|
62
|
50 |
|
protected function getConfigPath(): string |
|
63
|
|
|
{ |
|
64
|
50 |
|
return __DIR__ . '/../config/sms.php'; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
50 |
|
protected function registerConfig(): void |
|
68
|
|
|
{ |
|
69
|
50 |
|
if ($this->app instanceof Lumen) { |
|
70
|
|
|
$this->app->configure(self::SMS); |
|
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
50 |
|
$this->mergeConfigFrom($this->getConfigPath(), self::SMS); |
|
74
|
50 |
|
} |
|
75
|
|
|
|
|
76
|
50 |
|
protected function registerCommands(): void |
|
77
|
|
|
{ |
|
78
|
50 |
|
$this->app->singleton('command.sms.gateway', SmsSwitchConnectionCommand::class); |
|
79
|
50 |
|
$this->commands( |
|
80
|
|
|
[ |
|
81
|
50 |
|
'command.sms.gateway', |
|
82
|
|
|
] |
|
83
|
|
|
); |
|
84
|
50 |
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
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