Completed
Push — master ( b3fdf0...570788 )
by ARCANEDEV
03:05
created

AuthorizationServiceProvider::boot()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 2
rs 9.4285
1
<?php namespace Arcanesoft\Foundation\Providers;
2
3
use Arcanedev\Support\Providers\AuthorizationServiceProvider as ServiceProvider;
4
use Arcanesoft\Contracts\Auth\Models\User;
5
use Arcanesoft\Foundation\Policies;
6
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
7
8
/**
9
 * Class     AuthorizationServiceProvider
10
 *
11
 * @package  Arcanesoft\Foundation\Providers
12
 * @author   ARCANEDEV <[email protected]>
13
 */
14
class AuthorizationServiceProvider extends ServiceProvider
15
{
16
    /* ------------------------------------------------------------------------------------------------
17
     |  Main Functions
18
     | ------------------------------------------------------------------------------------------------
19
     */
20
    /**
21
     * Register any application authentication / authorization services.
22
     *
23
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
24
     */
25 12
    public function boot(GateContract $gate)
26
    {
27 12
        $this->registerPolicies($gate);
28
29
        /** @var  \Illuminate\Auth\Access\Gate  $gate */
30 12
        $gate->before(function (User $user, $ability) {
0 ignored issues
show
Unused Code introduced by
The parameter $ability is not used and could be removed.

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

Loading history...
31
            return $user->isAdmin() ? true : null;
32 12
        });
33
34 12
        $this->registerLogViewerPolicies($gate);
35 12
    }
36
37
    /**
38
     * Register LogViewer policies.
39
     *
40
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
41
     */
42 12
    private function registerLogViewerPolicies(GateContract $gate)
43
    {
44 12
        $this->defineMany(
45
            $gate,
46 12
            Policies\LogViewerPolicy::class,
47 12
            Policies\LogViewerPolicy::getPolicies()
48
        );
49 12
    }
50
}
51