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