1
|
|
|
<?php namespace Arcanesoft\Blog\Providers; |
2
|
|
|
|
3
|
|
|
use Arcanedev\Support\Providers\AuthorizationServiceProvider as ServiceProvider; |
4
|
|
|
use Arcanesoft\Blog\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
|
8 |
|
public function boot(GateContract $gate) |
38
|
|
|
{ |
39
|
8 |
|
parent::registerPolicies($gate); |
|
|
|
|
40
|
|
|
|
41
|
8 |
|
$this->registerPostsPolicies($gate); |
42
|
8 |
|
$this->registerCategoriesPolicies($gate); |
43
|
8 |
|
$this->registerTagsPolicies($gate); |
44
|
8 |
|
$this->registerOtherPolicies($gate); |
|
|
|
|
45
|
8 |
|
} |
46
|
|
|
|
47
|
|
|
/* ------------------------------------------------------------------------------------------------ |
48
|
|
|
| Policies |
49
|
|
|
| ------------------------------------------------------------------------------------------------ |
50
|
|
|
*/ |
51
|
|
|
/** |
52
|
|
|
* Register posts authorizations. |
53
|
|
|
* |
54
|
|
|
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
55
|
|
|
*/ |
56
|
8 |
|
private function registerPostsPolicies(GateContract $gate) |
57
|
|
|
{ |
58
|
8 |
|
$this->defineMany($gate, |
59
|
8 |
|
Policies\PostsPolicy::class, |
60
|
8 |
|
Policies\PostsPolicy::getPolicies() |
61
|
6 |
|
); |
62
|
8 |
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Register categories authorizations. |
66
|
|
|
* |
67
|
|
|
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
68
|
|
|
*/ |
69
|
8 |
|
private function registerCategoriesPolicies(GateContract $gate) |
70
|
|
|
{ |
71
|
8 |
|
$this->defineMany($gate, |
72
|
8 |
|
Policies\CategoriesPolicy::class, |
73
|
8 |
|
Policies\CategoriesPolicy::getPolicies() |
74
|
6 |
|
); |
75
|
8 |
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Register tags authorizations. |
79
|
|
|
* |
80
|
|
|
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
81
|
|
|
*/ |
82
|
8 |
|
private function registerTagsPolicies(GateContract $gate) |
83
|
|
|
{ |
84
|
8 |
|
$this->defineMany($gate, |
85
|
8 |
|
Policies\TagsPolicy::class, |
86
|
8 |
|
Policies\TagsPolicy::getPolicies() |
87
|
6 |
|
); |
88
|
8 |
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Register other authorizations for blog module. |
92
|
|
|
* |
93
|
|
|
* @param \Illuminate\Contracts\Auth\Access\Gate $gate |
94
|
|
|
*/ |
95
|
8 |
|
private function registerOtherPolicies(GateContract $gate) |
|
|
|
|
96
|
|
|
{ |
97
|
|
|
// |
98
|
8 |
|
} |
99
|
|
|
} |
100
|
|
|
|
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.