|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Symfony package. |
|
|
5 |
* |
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
7 |
* |
|
|
8 |
* For the full copyright and license information, please view the LICENSE |
|
|
9 |
* file that was distributed with this source code. |
|
|
10 |
*/ |
|
|
11 |
|
|
|
12 |
namespace Symfony\Component\Security\Acl\Domain; |
|
|
13 |
|
|
|
14 |
use Symfony\Component\Security\Acl\Exception\InvalidDomainObjectException; |
|
|
15 |
use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface; |
|
|
16 |
|
|
|
17 |
/** |
|
|
18 |
* Strategy to be used for retrieving object identities from domain objects |
|
|
19 |
* |
|
|
20 |
* @author Johannes M. Schmitt <schmittjoh@gmail.com> |
|
|
21 |
*/ |
|
|
22 |
class ObjectIdentityRetrievalStrategy implements ObjectIdentityRetrievalStrategyInterface |
|
|
23 |
{ |
|
|
24 |
/** |
|
|
25 |
* {@inheritDoc} |
|
|
26 |
*/ |
|
|
27 |
public function getObjectIdentity($domainObject) |
|
|
28 |
{ |
|
|
29 |
try { |
|
|
30 |
return ObjectIdentity::fromDomainObject($domainObject); |
|
|
31 |
} catch (InvalidDomainObjectException $failed) { |
|
|
32 |
return null; |
|
|
33 |
} |
|
|
34 |
} |
|
|
35 |
} |