Skip to content

Commit

Permalink
Merge pull request #182 from arubacao/master
Browse files Browse the repository at this point in the history
Improve ServiceProvider
  • Loading branch information
SammyK authored Jul 22, 2017
2 parents 893b323 + 4373ba5 commit 1ab1c80
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/LaravelFacebookSdk/LaravelFacebookSdkServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LaravelFacebookSdkServiceProvider extends ServiceProvider
*
* @var bool
*/
protected $defer = false;
protected $defer = true;

/**
* Bootstrap the application events.
Expand All @@ -18,6 +18,10 @@ class LaravelFacebookSdkServiceProvider extends ServiceProvider
*/
public function boot()
{
if (! $this->app->runningInConsole()) {
return;
}

if ($this->isLumen()) {
return;
}
Expand All @@ -34,11 +38,13 @@ public function boot()
*/
public function register()
{
if ($this->isLumen()) {
$this->app->configure('laravel-facebook-sdk');
}
$this->mergeConfigFrom(__DIR__.'/../config/laravel-facebook-sdk.php', 'laravel-facebook-sdk');

// Main Service
$this->app->bind('SammyK\LaravelFacebookSdk\LaravelFacebookSdk', function ($app) {
if ($this->isLumen()) {
$app->configure('laravel-facebook-sdk');
}
$config = $app['config']->get('laravel-facebook-sdk.facebook_config');

if (! isset($config['persistent_data_handler']) && isset($app['session.store'])) {
Expand All @@ -57,6 +63,18 @@ public function register()
});
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [
'SammyK\LaravelFacebookSdk\LaravelFacebookSdk',
];
}

private function isLumen()
{
return is_a(\app(), 'Laravel\Lumen\Application');
Expand Down

0 comments on commit 1ab1c80

Please sign in to comment.