1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Illuminate\Notifications; |
4
|
|
|
|
5
|
|
|
use Illuminate\Notifications\Console\NotificationMakeCommand; |
6
|
|
|
use Illuminate\Notifications\Console\NotificationTableCommand; |
7
|
|
|
use Illuminate\Support\ServiceProvider; |
8
|
|
|
use Illuminate\Contracts\Notifications\Factory as FactoryContract; |
9
|
|
|
use Illuminate\Contracts\Notifications\Dispatcher as DispatcherContract; |
10
|
|
|
use Illuminate\Bus\Dispatcher as Bus; |
11
|
|
|
|
12
|
|
|
class NotificationServiceProvider extends ServiceProvider |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Boot the application services. |
16
|
|
|
* |
17
|
|
|
* @return void |
18
|
|
|
*/ |
19
|
|
|
public function boot() |
20
|
|
|
{ |
21
|
|
|
$this->loadViewsFrom(__DIR__.'/resources/views', 'notifications'); |
22
|
|
|
|
23
|
|
|
if ($this->app->runningInConsole()) { |
|
|
|
|
24
|
|
|
$this->publishes([ |
25
|
|
|
__DIR__.'/resources/views' => $this->app->basePath().'/resources/views/vendor/notifications', |
26
|
|
|
], 'laravel-notifications'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
if (version_compare($this->getAppVersion(), '5.2', '<')) { |
30
|
|
|
$this->app->make(Bus::class)->maps([ |
31
|
|
|
SendQueuedNotifications::class => SendQueuedNotificationsHandler::class . '@handle', |
32
|
|
|
]); |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Register the service provider. |
38
|
|
|
* |
39
|
|
|
* @return void |
40
|
|
|
*/ |
41
|
|
|
public function register() |
42
|
|
|
{ |
43
|
|
|
$this->registerCommands(); |
44
|
|
|
|
45
|
|
|
$this->app->singleton(ChannelManager::class, function ($app) { |
46
|
|
|
return new ChannelManager($app); |
47
|
|
|
}); |
48
|
|
|
|
49
|
|
|
$this->app->alias( |
50
|
|
|
ChannelManager::class, DispatcherContract::class |
51
|
|
|
); |
52
|
|
|
|
53
|
|
|
$this->app->alias( |
54
|
|
|
ChannelManager::class, FactoryContract::class |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
protected function registerCommands() |
59
|
|
|
{ |
60
|
|
|
$this->app->singleton('command.notification.make', function ($app) { |
61
|
|
|
return new NotificationMakeCommand($app['files']); |
62
|
|
|
}); |
63
|
|
|
|
64
|
|
|
$this->app->singleton('command.notification.table', function ($app) { |
65
|
|
|
return new NotificationTableCommand($app['files'], $app['composer']); |
66
|
|
|
}); |
67
|
|
|
|
68
|
|
|
$this->commands([ |
69
|
|
|
'command.notification.make', |
70
|
|
|
'command.notification.table' |
71
|
|
|
]); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Get the version number of the application. |
76
|
|
|
* |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
|
private function getAppVersion() |
80
|
|
|
{ |
81
|
|
|
$version = $this->app->version(); |
82
|
|
|
if (substr($version, 0, 7) === 'Lumen (') { |
83
|
|
|
$version = array_first(explode(')', str_replace('Lumen (', '', $version))); |
84
|
|
|
} |
85
|
|
|
return $version; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.