Passed
Push — master ( c33ae4...c590b7 )
by Monney
10:15
created

bootInstagramSocialite()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Mckenziearts\LaravelOAuth;
4
5
use Illuminate\Support\ServiceProvider;
6
use Mckenziearts\LaravelOAuth\Providers\InstagramProvider;
7
8
class LaravelOAuthServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Perform post-registration booting of services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        $this->loadTranslationsFrom(__DIR__.'/Lang', 'laravel-oauth');
18
19
        $this->publishes([
20
            __DIR__.'/../public/assets' => public_path('vendor/mckenziearts/laravel-oauth/assets'),
21
        ], 'laravel-oauth.assets');
22
        $this->publishes([
23
            __DIR__.'/../migrations/' => database_path('migrations'),
24
        ], 'laravel-oauth.migrations');
25
        $this->publishes([
26
            __DIR__.'/../config/laravel-oauth.php' => config_path('laravel-oauth.php'),
27
        ], 'laravel-oauth.config');
28
        $this->publishes([
29
            __DIR__.'/Lang' => resource_path('lang/vendor/mckenziearts'),
30
        ], 'laravel-oauth.views');
31
32
        // Boot all new OAuth 2 Provider added to Socialite
33
        $this->bootInstagramSocialite();
34
    }
35
36
    /**
37
     * Register any package services.
38
     *
39
     * @return void
40
     */
41
    public function register()
42
    {
43
        $this->mergeConfigFrom(__DIR__.'/../config/laravel-oauth.php', 'laravel-oauth');
44
45
        /*
46
         * Register the Laravel/socialite service provider
47
         */
48
        $this->app->register(\Laravel\Socialite\SocialiteServiceProvider::class);
49
50
        // Register custom blade directive
51
        $this->app->register(\Mckenziearts\LaravelOAuth\Providers\BladeServiceProvider::class);
52
53
        /*
54
         * Create aliases for the dependency.
55
         */
56
        $loader = \Illuminate\Foundation\AliasLoader::getInstance();
57
        $loader->alias('Socialite', \Laravel\Socialite\Facades\Socialite::class);
58
59
        // Register the service the package provides.
60
        $this->app->singleton('laravelsocialite', function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

60
        $this->app->singleton('laravelsocialite', function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
61
            return new LaravelSocialite;
62
        });
63
        // Create aliase for the package provider
64
        $loader->alias('LaravelSocialite', \Mckenziearts\LaravelOAuth\Facades\LaravelSocialite::class);
65
    }
66
67
    /**
68
     * Add Instagram to Socialite
69
     */
70
    private function bootInstagramSocialite()
71
    {
72
        $socialite = $this->app->make(\Laravel\Socialite\Contracts\Factory::class);
73
        $socialite->extend(
74
            'instagram',
75
            function ($app) use ($socialite) {
76
                $config = $app['config']['services.instagram'];
77
                return $socialite->buildProvider(InstagramProvider::class, $config);
78
            }
79
        );
80
    }
81
82
    /**
83
     * Get the services provided by the provider.
84
     *
85
     * @return array
86
     */
87
    public function provides()
88
    {
89
        return ['laravelsocialite'];
90
    }
91
}
92