1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Mckenziearts\LaravelOAuth; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Mckenziearts\LaravelOAuth\Providers\DribbbleProvider; |
7
|
|
|
use Mckenziearts\LaravelOAuth\Providers\InstagramProvider; |
8
|
|
|
use Mckenziearts\LaravelOAuth\Providers\PinterestProvider; |
9
|
|
|
|
10
|
|
|
class LaravelOAuthServiceProvider extends ServiceProvider |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Perform post-registration booting of services. |
14
|
|
|
* |
15
|
|
|
* @return void |
16
|
|
|
*/ |
17
|
|
|
public function boot() |
18
|
|
|
{ |
19
|
|
|
$this->loadTranslationsFrom(__DIR__.'/Lang', 'laravel-oauth'); |
20
|
|
|
|
21
|
|
|
$this->publishes([ |
22
|
|
|
__DIR__.'/../public/assets' => public_path('vendor/mckenziearts/laravel-oauth/assets'), |
23
|
|
|
], 'laravel-oauth.assets'); |
24
|
|
|
$this->publishes([ |
25
|
|
|
__DIR__.'/../migrations/' => database_path('migrations'), |
26
|
|
|
], 'laravel-oauth.migrations'); |
27
|
|
|
$this->publishes([ |
28
|
|
|
__DIR__.'/../config/laravel-oauth.php' => config_path('laravel-oauth.php'), |
29
|
|
|
], 'laravel-oauth.config'); |
30
|
|
|
$this->publishes([ |
31
|
|
|
__DIR__.'/Lang' => resource_path('lang/vendor/mckenziearts'), |
32
|
|
|
], 'laravel-oauth.views'); |
33
|
|
|
|
34
|
|
|
// Boot all new OAuth 2 Provider added to Socialite |
35
|
|
|
$this->bootInstagramSocialite(); |
36
|
|
|
$this->bootDribbbleSocialite(); |
37
|
|
|
$this->bootPinterestSocialite(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Register any package services. |
42
|
|
|
* |
43
|
|
|
* @return void |
44
|
|
|
*/ |
45
|
|
|
public function register() |
46
|
|
|
{ |
47
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/laravel-oauth.php', 'laravel-oauth'); |
48
|
|
|
|
49
|
|
|
/* |
50
|
|
|
* Register the Laravel/socialite service provider |
51
|
|
|
*/ |
52
|
|
|
$this->app->register(\Laravel\Socialite\SocialiteServiceProvider::class); |
53
|
|
|
|
54
|
|
|
// Register custom blade directive |
55
|
|
|
$this->app->register(\Mckenziearts\LaravelOAuth\Providers\BladeServiceProvider::class); |
56
|
|
|
|
57
|
|
|
/* |
58
|
|
|
* Create aliases for the dependency. |
59
|
|
|
*/ |
60
|
|
|
$loader = \Illuminate\Foundation\AliasLoader::getInstance(); |
61
|
|
|
$loader->alias('Socialite', \Laravel\Socialite\Facades\Socialite::class); |
62
|
|
|
|
63
|
|
|
// Register the service the package provides. |
64
|
|
|
$this->app->singleton('laravelsocialite', function ($app) { |
|
|
|
|
65
|
|
|
return new LaravelSocialite; |
66
|
|
|
}); |
67
|
|
|
// Create aliase for the package provider |
68
|
|
|
$loader->alias('LaravelSocialite', \Mckenziearts\LaravelOAuth\Facades\LaravelSocialite::class); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Get the services provided by the provider. |
73
|
|
|
* |
74
|
|
|
* @return array |
75
|
|
|
*/ |
76
|
|
|
public function provides() |
77
|
|
|
{ |
78
|
|
|
return ['laravelsocialite']; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
private function bootInstagramSocialite() |
82
|
|
|
{ |
83
|
|
|
$socialite = $this->app->make(\Laravel\Socialite\Contracts\Factory::class); |
84
|
|
|
$socialite->extend( |
85
|
|
|
'instagram', |
86
|
|
|
function ($app) use ($socialite) { |
87
|
|
|
$config = $app['config']['services.instagram']; |
88
|
|
|
|
89
|
|
|
return $socialite->buildProvider(InstagramProvider::class, $config); |
90
|
|
|
} |
91
|
|
|
); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
private function bootDribbbleSocialite() |
95
|
|
|
{ |
96
|
|
|
$socialite = $this->app->make(\Laravel\Socialite\Contracts\Factory::class); |
97
|
|
|
$socialite->extend( |
98
|
|
|
'dribbble', |
99
|
|
|
function ($app) use ($socialite) { |
100
|
|
|
$config = $app['config']['services.dribbble']; |
101
|
|
|
|
102
|
|
|
return $socialite->buildProvider(DribbbleProvider::class, $config); |
103
|
|
|
} |
104
|
|
|
); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
private function bootPinterestSocialite() |
108
|
|
|
{ |
109
|
|
|
$socialite = $this->app->make(\Laravel\Socialite\Contracts\Factory::class); |
110
|
|
|
$socialite->extend( |
111
|
|
|
'pinterest', |
112
|
|
|
function ($app) use ($socialite) { |
113
|
|
|
$config = $app['config']['services.pinterest']; |
114
|
|
|
|
115
|
|
|
return $socialite->buildProvider(PinterestProvider::class, $config); |
116
|
|
|
} |
117
|
|
|
); |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.