1 | <?php |
||
9 | class WebPushServiceProvider extends ServiceProvider |
||
10 | { |
||
11 | /** |
||
12 | * Register the application services. |
||
13 | * |
||
14 | * @return void |
||
15 | */ |
||
16 | 13 | public function register() |
|
22 | |||
23 | /** |
||
24 | * Bootstrap the application services. |
||
25 | * |
||
26 | * @return void |
||
27 | */ |
||
28 | 13 | public function boot() |
|
29 | { |
||
30 | 13 | $this->app->when(WebPushChannel::class) |
|
31 | 13 | ->needs(WebPush::class) |
|
32 | 13 | ->give(function () { |
|
33 | return new WebPush($this->webPushConfig()); |
||
34 | 13 | }); |
|
35 | |||
36 | 13 | if ($this->app->runningInConsole()) { |
|
37 | 13 | $this->definePublishing(); |
|
38 | } |
||
39 | 13 | } |
|
40 | |||
41 | /** |
||
42 | * @return array |
||
43 | */ |
||
44 | protected function webPushConfig() |
||
45 | { |
||
46 | $config = []; |
||
47 | $webpush = config('webpush'); |
||
48 | $publicKey = $webpush['vapid']['public_key']; |
||
49 | $privateKey = $webpush['vapid']['private_key']; |
||
50 | |||
51 | if (! empty($webpush['gcm']['key'])) { |
||
52 | $config['GCM'] = $webpush['gcm']['key']; |
||
53 | } |
||
54 | |||
55 | if (empty($publicKey) || empty($privateKey)) { |
||
56 | return $config; |
||
57 | } |
||
58 | |||
59 | $config['VAPID'] = compact('publicKey', 'privateKey'); |
||
60 | $config['VAPID']['subject'] = $webpush['vapid']['subject']; |
||
61 | |||
62 | if (empty($config['VAPID']['subject'])) { |
||
63 | $config['VAPID']['subject'] = url('/'); |
||
64 | } |
||
65 | |||
66 | if (! empty($webpush['vapid']['pem_file'])) { |
||
67 | $config['VAPID']['pemFile'] = $webpush['vapid']['pem_file']; |
||
68 | |||
69 | if (Str::startsWith($config['VAPID']['pemFile'], 'storage')) { |
||
70 | $config['VAPID']['pemFile'] = base_path($config['VAPID']['pemFile']); |
||
71 | } |
||
72 | } |
||
73 | |||
74 | return $config; |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Define the publishable migrations and resources. |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | 13 | protected function definePublishing() |
|
96 | } |
||
97 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.