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
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
private const SMS = 'sms'; |
23
|
|
|
|
24
|
51 |
|
public function boot(): void |
25
|
|
|
{ |
26
|
51 |
|
if (! $this->app->runningInConsole()) { |
27
|
|
|
return; |
28
|
|
|
} |
29
|
|
|
|
30
|
51 |
|
if (! $this->app instanceof Laravel) { |
31
|
|
|
return; |
32
|
|
|
} |
33
|
|
|
|
34
|
51 |
|
$this->publishes([ |
35
|
51 |
|
$this->getConfigPath() => config_path('sms.php'), |
36
|
51 |
|
], 'config'); |
37
|
|
|
} |
38
|
|
|
|
39
|
51 |
|
public function register(): void |
40
|
|
|
{ |
41
|
51 |
|
$this->registerConfig(); |
42
|
51 |
|
Notification::resolved( |
43
|
51 |
|
function (ChannelManager $service): void { |
44
|
11 |
|
$service->extend(self::SMS, function (Container $app) { |
45
|
2 |
|
return $app->make(SmsChannel::class); |
46
|
|
|
}); |
47
|
|
|
} |
48
|
|
|
); |
49
|
51 |
|
$this->app->singleton(self::SMS, function (Container $app) { |
50
|
12 |
|
return $app->make(SmsManager::class); |
51
|
|
|
}); |
52
|
51 |
|
$this->app->alias(self::SMS, Sms::class); |
53
|
51 |
|
$this->registerCommands(); |
54
|
|
|
} |
55
|
|
|
|
56
|
51 |
|
protected function getConfigPath(): string |
57
|
|
|
{ |
58
|
51 |
|
return __DIR__ . '/../config/sms.php'; |
59
|
|
|
} |
60
|
|
|
|
61
|
51 |
|
protected function registerConfig(): void |
62
|
|
|
{ |
63
|
51 |
|
if ($this->app instanceof Lumen) { |
64
|
|
|
$this->app->configure(self::SMS); |
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
51 |
|
$this->mergeConfigFrom($this->getConfigPath(), self::SMS); |
68
|
|
|
} |
69
|
|
|
|
70
|
51 |
|
protected function registerCommands(): void |
71
|
|
|
{ |
72
|
51 |
|
$this->app->singleton('command.sms.gateway', SmsSwitchConnectionCommand::class); |
73
|
51 |
|
$this->commands(['command.sms.gateway']); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
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