1 | <?php |
||
19 | class Firewall |
||
20 | { |
||
21 | const ROLE_ADMIN = 'ROLE_ADMIN'; |
||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $routes = []; |
||
27 | |||
28 | /** |
||
29 | * @param string|array $methods |
||
30 | * @param string $path |
||
31 | * @param string $role |
||
32 | */ |
||
33 | 21 | public function addRoute($methods, $path, $role) |
|
41 | |||
42 | /** |
||
43 | * @param string $method |
||
44 | * @param string $uri |
||
45 | * @param HasRolesInterface|null $user |
||
46 | * |
||
47 | * @return bool |
||
48 | */ |
||
49 | 21 | public function isGranted($method, $uri, HasRolesInterface $user = null) |
|
61 | |||
62 | /** |
||
63 | * @param string $method |
||
64 | * @param string $path |
||
65 | * @param array $route |
||
66 | * @param HasRolesInterface|null $user |
||
67 | * |
||
68 | * @return bool |
||
69 | */ |
||
70 | 12 | protected function isGrantedRoute($method, $path, $route, HasRolesInterface $user = null) |
|
84 | |||
85 | /** |
||
86 | * @param string $method |
||
87 | * @param string $uri |
||
88 | * @param string $route |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | 21 | protected function isUriInRoutes($method, $uri, $route) |
|
108 | |||
109 | /** |
||
110 | * @param HasRolesInterface $user |
||
111 | * @param string $role |
||
112 | * |
||
113 | * @return bool |
||
114 | */ |
||
115 | 10 | protected function hasRole(HasRolesInterface $user, $role) |
|
119 | |||
120 | /** |
||
121 | * @return array |
||
122 | */ |
||
123 | 21 | protected function getRoutes() |
|
127 | } |
||
128 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.