Skip to content

Commit

Permalink
Merge pull request #97 from klimov-paul/defer-data-provider
Browse files Browse the repository at this point in the history
Improve Service Provider
  • Loading branch information
Edujugon authored Sep 11, 2019
2 parents 995a416 + b9ae473 commit 9ab69b7
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/Providers/PushNotificationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace Edujugon\PushNotification\Providers;

use Edujugon\PushNotification\PushNotification;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;

class PushNotificationServiceProvider extends ServiceProvider
class PushNotificationServiceProvider extends ServiceProvider implements DeferrableProvider
{
/**
* Bootstrap the application services.
Expand All @@ -14,23 +15,38 @@ class PushNotificationServiceProvider extends ServiceProvider
*/
public function boot()
{
$config_path = function_exists('config_path') ? config_path('pushnotification.php') : 'pushnotification.php';
if (! $this->app->runningInConsole()) {
return;
}

$configPath = $this->app->make('path.config');

$this->publishes([
__DIR__.'/../Config/config.php' => $config_path,
__DIR__.'/../Config/iosCertificates' => config_path('iosCertificates/')
__DIR__.'/../Config/config.php' => $configPath.'/pushnotification.php',
__DIR__.'/../Config/iosCertificates' => $configPath.'/iosCertificates/',
], 'config');
}

/**
* Register the application services.
*
* @return void
* {@inheritdoc}
*/
public function register()
{
$this->app->singleton('edujugonPushNotification', function ($app) {
return new PushNotification();
});

$this->app->bind(PushNotification::class, 'edujugonPushNotification');
}

/**
* {@inheritdoc}
*/
public function provides()
{
return [
PushNotification::class,
'edujugonPushNotification',
];
}
}

0 comments on commit 9ab69b7

Please sign in to comment.