File tree 4 files changed +34
-2
lines changed
4 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -28,4 +28,12 @@ public function getExcludeMethods(): array;
28
28
* @return string
29
29
*/
30
30
public function getAppendTo (): string ;
31
+
32
+ /**
33
+ * All permissions ignored if true
34
+ *
35
+ * @return bool
36
+ */
37
+ public function isPermissionsIgnored (): bool ;
38
+
31
39
}
Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ protected function sectionPermissions()
177
177
}
178
178
}
179
179
180
- if (!empty ($ sectionWisePermissions )) {
180
+ if (!empty ($ sectionWisePermissions ) && array_key_exists ( $ section , $ sectionWisePermissions ) ) {
181
181
ksort ($ sectionWisePermissions [$ section ]['permissions ' ]);
182
182
}
183
183
}
Original file line number Diff line number Diff line change @@ -87,6 +87,10 @@ public function generate()
87
87
88
88
// if the controller use the WithPermissible interface then find the excluded routes
89
89
if ($ controllerInstance instanceof WithPermissionGenerator) {
90
+ if ($ controllerInstance ->isPermissionsIgnored ()) {
91
+ continue ;
92
+ }
93
+
90
94
$ controllerMethod = $ actionExtract [1 ];
91
95
92
96
$ excludeMethods = $ controllerInstance ->getExcludeMethods ();
@@ -96,7 +100,7 @@ public function generate()
96
100
}
97
101
}
98
102
99
- // check is the current route store in onlyPermissionNames in order to avoid duplicacy
103
+ // check is the current route store in onlyPermissionNames in order to avoid duplicity
100
104
if (in_array ($ routeName , $ onlyPermissionNames )) {
101
105
continue ;
102
106
}
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ trait PermissionGenerator
8
8
{
9
9
private $ title = '' ;
10
10
11
+ private $ ignore = false ;
12
+
11
13
private $ excludeMethods = [];
12
14
13
15
private $ appendTo = '' ;
@@ -54,6 +56,19 @@ protected function permissionsAppendTo(string $key)
54
56
return $ this ;
55
57
}
56
58
59
+ /**
60
+ * Permission ignored when value true
61
+ *
62
+ * @param boolean $ignore
63
+ * @return void
64
+ */
65
+ protected function permissionsIgnoreWhen (bool $ ignore )
66
+ {
67
+ $ this ->ignore = $ ignore ;
68
+
69
+ return $ this ;
70
+ }
71
+
57
72
/**
58
73
* @return string
59
74
*/
@@ -77,4 +92,9 @@ public function getAppendTo(): string
77
92
{
78
93
return $ this ->appendTo ;
79
94
}
95
+
96
+ public function isPermissionsIgnored (): bool
97
+ {
98
+ return $ this ->ignore ;
99
+ }
80
100
}
You can’t perform that action at this time.
0 commit comments