1
|
|
|
<?php namespace Arcanesoft\Auth\Providers; |
2
|
|
|
|
3
|
|
|
use Arcanedev\Support\Providers\AuthorizationServiceProvider as ServiceProvider; |
4
|
|
|
use Arcanesoft\Auth\Policies; |
5
|
|
|
use Illuminate\Contracts\Auth\Access\Gate as GateContract; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class AuthorizationServiceProvider |
9
|
|
|
* |
10
|
|
|
* @package Arcanesoft\Auth\Providers |
11
|
|
|
* @author ARCANEDEV <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
class AuthorizationServiceProvider extends ServiceProvider |
14
|
|
|
{ |
15
|
|
|
/* ------------------------------------------------------------------------------------------------ |
16
|
|
|
| Properties |
17
|
|
|
| ------------------------------------------------------------------------------------------------ |
18
|
|
|
*/ |
19
|
|
|
/** |
20
|
|
|
* The policy mappings for the application. |
21
|
|
|
* |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
protected $policies = [ |
25
|
|
|
// |
26
|
|
|
]; |
27
|
|
|
|
28
|
|
|
/* ------------------------------------------------------------------------------------------------ |
29
|
|
|
| Main Functions |
30
|
|
|
| ------------------------------------------------------------------------------------------------ |
31
|
|
|
*/ |
32
|
|
|
/** |
33
|
|
|
* Register any application authentication / authorization services. |
34
|
|
|
* |
35
|
|
|
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
36
|
|
|
*/ |
37
|
12 |
|
public function boot(GateContract $gate) |
38
|
|
|
{ |
39
|
12 |
|
parent::registerPolicies(); |
|
|
|
|
40
|
|
|
|
41
|
12 |
|
$this->registerDashboardPolicies($gate); |
42
|
12 |
|
$this->registerUsersPolicies($gate); |
43
|
12 |
|
$this->registerRolesPolicies($gate); |
44
|
12 |
|
$this->registerPermissionsPolicies($gate); |
45
|
12 |
|
$this->registerPasswordResetsPolicies($gate); |
46
|
12 |
|
} |
47
|
|
|
|
48
|
|
|
/* ------------------------------------------------------------------------------------------------ |
49
|
|
|
| Policies |
50
|
|
|
| ------------------------------------------------------------------------------------------------ |
51
|
|
|
*/ |
52
|
|
|
/** |
53
|
|
|
* Register dashboard authorizations. |
54
|
|
|
* |
55
|
|
|
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
56
|
|
|
*/ |
57
|
12 |
|
private function registerDashboardPolicies($gate) |
58
|
|
|
{ |
59
|
12 |
|
$this->defineMany($gate, |
60
|
12 |
|
Policies\DashboardPolicy::class, |
61
|
12 |
|
Policies\DashboardPolicy::getPolicies() |
62
|
12 |
|
); |
63
|
12 |
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Register users authorizations. |
67
|
|
|
* |
68
|
|
|
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
69
|
|
|
*/ |
70
|
12 |
|
private function registerUsersPolicies(GateContract $gate) |
71
|
|
|
{ |
72
|
12 |
|
$this->defineMany($gate, |
73
|
12 |
|
Policies\UsersPolicy::class, |
74
|
12 |
|
Policies\UsersPolicy::getPolicies() |
75
|
12 |
|
); |
76
|
12 |
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Register roles authorizations. |
80
|
|
|
* |
81
|
|
|
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
82
|
|
|
*/ |
83
|
12 |
|
private function registerRolesPolicies(GateContract $gate) |
84
|
|
|
{ |
85
|
12 |
|
$this->defineMany($gate, |
86
|
12 |
|
Policies\RolesPolicy::class, |
87
|
12 |
|
Policies\RolesPolicy::getPolicies() |
88
|
12 |
|
); |
89
|
12 |
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Register permissions authorizations. |
93
|
|
|
* |
94
|
|
|
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
95
|
|
|
*/ |
96
|
12 |
|
private function registerPermissionsPolicies(GateContract $gate) |
97
|
|
|
{ |
98
|
12 |
|
$this->defineMany($gate, |
99
|
12 |
|
Policies\PermissionsPolicy::class, |
100
|
12 |
|
Policies\PermissionsPolicy::getPolicies() |
101
|
12 |
|
); |
102
|
12 |
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Register password resets authorizations. |
106
|
|
|
* |
107
|
|
|
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
108
|
|
|
*/ |
109
|
12 |
|
private function registerPasswordResetsPolicies(GateContract $gate) |
110
|
|
|
{ |
111
|
12 |
|
$this->defineMany($gate, |
112
|
12 |
|
Policies\PasswordResetsPolicy::class, |
113
|
12 |
|
Policies\PasswordResetsPolicy::getPolicies() |
114
|
12 |
|
); |
115
|
12 |
|
} |
116
|
|
|
} |
117
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.