|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* Copyright 2010 Johannes M. Schmitt <schmittjoh@gmail.com> |
|
|
5 |
* |
|
|
6 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
7 |
* you may not use this file except in compliance with the License. |
|
|
8 |
* You may obtain a copy of the License at |
|
|
9 |
* |
|
|
10 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
|
11 |
* |
|
|
12 |
* Unless required by applicable law or agreed to in writing, software |
|
|
13 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
|
14 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
|
15 |
* See the License for the specific language governing permissions and |
|
|
16 |
* limitations under the License. |
|
|
17 |
*/ |
|
|
18 |
|
|
|
19 |
namespace JMS\SecurityExtraBundle\Security\Authorization\AfterInvocation; |
|
|
20 |
|
|
|
21 |
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; |
|
|
22 |
|
|
|
23 |
/** |
|
|
24 |
* This is the pendant to the AccessDecisionManager which is used to make |
|
|
25 |
* access decisions after a method has been executed. |
|
|
26 |
* |
|
|
27 |
* @author Johannes M. Schmitt <schmittjoh@gmail.com> |
|
|
28 |
*/ |
|
|
29 |
class AfterInvocationManager implements AfterInvocationManagerInterface |
|
|
30 |
{ |
|
|
31 |
private $providers; |
|
|
32 |
|
|
|
33 |
public function __construct(array $providers) |
|
|
34 |
{ |
|
|
35 |
$this->providers = $providers; |
|
|
36 |
} |
|
|
37 |
|
|
|
38 |
/** |
|
|
39 |
* {@inheritDoc} |
|
|
40 |
*/ |
|
|
41 |
public function decide(TokenInterface $token, $secureInvocation, array $attributes, $returnedObject) |
|
|
42 |
{ |
|
|
43 |
foreach ($this->providers as $provider) { |
|
|
44 |
$returnedObject = $provider->decide($token, $secureInvocation, $attributes, $returnedObject); |
|
|
45 |
} |
|
|
46 |
|
|
|
47 |
return $returnedObject; |
|
|
48 |
} |
|
|
49 |
|
|
|
50 |
/** |
|
|
51 |
* {@inheritDoc} |
|
|
52 |
*/ |
|
|
53 |
public function supportsAttribute($attribute) |
|
|
54 |
{ |
|
|
55 |
foreach ($this->providers as $provider) { |
|
|
56 |
if (true === $provider->supportsAttribute($attribute)) { |
|
|
57 |
return true; |
|
|
58 |
} |
|
|
59 |
} |
|
|
60 |
|
|
|
61 |
return false; |
|
|
62 |
} |
|
|
63 |
|
|
|
64 |
/** |
|
|
65 |
* {@inheritDoc} |
|
|
66 |
*/ |
|
|
67 |
public function supportsClass($className) |
|
|
68 |
{ |
|
|
69 |
foreach ($this->providers as $provider) { |
|
|
70 |
if (true === $provider->supportsClass($className)) { |
|
|
71 |
return true; |
|
|
72 |
} |
|
|
73 |
} |
|
|
74 |
|
|
|
75 |
return false; |
|
|
76 |
} |
|
|
77 |
} |