1 | <?php |
||
11 | class SecurityMiddleware implements Middleware |
||
12 | { |
||
13 | /** |
||
14 | * Access denied behavior to drop the command if not allowed. |
||
15 | */ |
||
16 | const DROP_COMMAND = 1; |
||
17 | |||
18 | /** |
||
19 | * Access denied behavior to throw an AccessDenied exception if not allowed. |
||
20 | * Default behavior. |
||
21 | */ |
||
22 | const THROW_ACCESS_DENIED_EXCEPTION = 2; |
||
23 | |||
24 | /** |
||
25 | * @var int |
||
26 | */ |
||
27 | private $accessDeniedBehavior; |
||
28 | |||
29 | /** |
||
30 | * @var AuthorizationCheckerInterface |
||
31 | */ |
||
32 | private $authorizationChecker; |
||
33 | |||
34 | /** |
||
35 | * @param AuthorizationCheckerInterface $authorizationChecker |
||
36 | */ |
||
37 | public function __construct(AuthorizationCheckerInterface $authorizationChecker, $accessDeniedBehavior = self::THROW_ACCESS_DENIED_EXCEPTION) { |
||
47 | |||
48 | /** |
||
49 | * @param object $command |
||
50 | * @param callable $next |
||
51 | * @return mixed |
||
52 | */ |
||
53 | public function execute($command, callable $next) |
||
63 | } |
||
64 | |||
65 |