Completed
Pull Request — master (#83)
by D.
04:14 queued 01:25
created

AppServiceProvider::setupLdap()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 6
1
<?php
2
3
namespace SET\Providers;
4
5
use Illuminate\Support\Facades\Cache;
6
use Illuminate\Support\ServiceProvider;
7
use SET\Handlers\DBConfigs\DBConfigs;
8
use SET\Setting;
9
10
class AppServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Bootstrap any application services.
14
     *
15
     * @return void
16
     */
17 162
    public function boot()
18
    {
19
        // Ensure installation is not in progress
20 162
        if (!strpos(url()->current(), 'install')) {
21 162
            DBConfigs::execute();
22
            $this->setupLdap();
23
        }
24 162
25 10
        Setting::saving(function ($setting) {
26 162
            Cache::forever($setting->key, $setting->value);
27 162
        });
28
    }
29
30
    /**
31
     * Register any application services.
32
     *
33
     * @return void
34 162
     */
35
    public function register()
36 162
    {
37
        if ($this->app->environment() == 'local') {
38
            $this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
39 162
        }
40
    }
41
42
    private function setupLdap()
43
    {
44
        if (config('auth.providers.users.driver') == 'adldap') {
45
            $this->app->register('Adldap\Laravel\AdldapServiceProvider');
46
            $this->app->register('Adldap\Laravel\AdldapAuthServiceProvider');
47
        }
48
    }
49
}
50