1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* |
5
|
|
|
* (c) Yaroslav Honcharuk <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Yarhon\RouteGuardBundle\Security\AuthorizationChecker; |
12
|
|
|
|
13
|
|
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface as BaseAuthorizationCheckerInterface; |
14
|
|
|
use Yarhon\RouteGuardBundle\Routing\RouteContextInterface; |
15
|
|
|
use Yarhon\RouteGuardBundle\Security\Test\TestInterface; |
16
|
|
|
use Yarhon\RouteGuardBundle\Security\Test\AbstractSymfonySecurityTest; |
17
|
|
|
use Yarhon\RouteGuardBundle\Security\TestResolver\SymfonySecurityResolverInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Yaroslav Honcharuk <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class SymfonySecurityAuthorizationChecker implements AuthorizationCheckerInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var BaseAuthorizationCheckerInterface |
26
|
|
|
*/ |
27
|
|
|
private $authorizationChecker; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var SymfonySecurityResolverInterface |
31
|
|
|
*/ |
32
|
|
|
private $testResolver; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param BaseAuthorizationCheckerInterface $authorizationChecker |
36
|
|
|
* @param SymfonySecurityResolverInterface $testResolver |
37
|
|
|
*/ |
38
|
22 |
|
public function __construct(BaseAuthorizationCheckerInterface $authorizationChecker, SymfonySecurityResolverInterface $testResolver) |
39
|
|
|
{ |
40
|
22 |
|
$this->authorizationChecker = $authorizationChecker; |
41
|
22 |
|
$this->testResolver = $testResolver; |
42
|
22 |
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
47
|
15 |
|
public function isGranted(TestInterface $test, RouteContextInterface $routeContext) |
48
|
|
|
{ |
49
|
15 |
|
$arguments = $this->testResolver->resolve($test, $routeContext); |
50
|
|
|
|
51
|
15 |
|
return $this->authorizationChecker->isGranted(...$arguments); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
15 |
|
public function supports(TestInterface $test) |
58
|
|
|
{ |
59
|
15 |
|
return $test instanceof AbstractSymfonySecurityTest; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|