Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3.243 |
Changes | 0 |
1 | <?php |
||
29 | 6 | public function execute($command, callable $next) |
|
30 | { |
||
31 | 6 | if (null === $this->authorizationChecker) { |
|
32 | throw new \Exception( |
||
33 | "The Security Middleware requires the authorization checker service (@security.authorization_checker) to be present and configured." . |
||
34 | "Please active security extension in your config." |
||
35 | ); |
||
36 | } |
||
37 | |||
38 | 6 | if ($this->authorizationChecker->isGranted('handle', $command)) { |
|
39 | 3 | return $next($command); |
|
40 | } else { |
||
41 | 3 | throw new AccessDeniedException( |
|
42 | 3 | sprintf('The current user is not allowed to handle command of type \'%s\'', get_class($command)) |
|
43 | 2 | ); |
|
44 | } |
||
45 | } |
||
46 | } |
||
48 |