Skip to content

Commit

Permalink
[5.8] Use Facade::resolved() before extending channel
Browse files Browse the repository at this point in the history
This allow nexmo notification to only be loaded when/if the notification is resolved. Based on PR made to <laravel/framework#26824>
  • Loading branch information
crynobone authored Jan 6, 2019
1 parent 9b3ac5e commit 3c8e8fb
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/NexmoChannelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Nexmo\Client as NexmoClient;
use Illuminate\Support\ServiceProvider;
use Illuminate\Notifications\ChannelManager;
use Illuminate\Support\Facades\Notification;
use Nexmo\Client\Credentials\Basic as NexmoCredentials;

Expand All @@ -16,14 +17,16 @@ class NexmoChannelServiceProvider extends ServiceProvider
*/
public function register()
{
Notification::extend('nexmo', function ($app) {
return new Channels\NexmoSmsChannel(
new NexmoClient(new NexmoCredentials(
$this->app['config']['services.nexmo.key'],
$this->app['config']['services.nexmo.secret']
)),
$this->app['config']['services.nexmo.sms_from']
);
Notification::resolved(function (ChannelManager $service) {
$service->extend('nexmo', function ($app) {
return new Channels\NexmoSmsChannel(
new NexmoClient(new NexmoCredentials(
$this->app['config']['services.nexmo.key'],
$this->app['config']['services.nexmo.secret']
)),
$this->app['config']['services.nexmo.sms_from']
);
});
});
}
}

0 comments on commit 3c8e8fb

Please sign in to comment.