diff options
Diffstat (limited to 'Acl/Domain/ObjectIdentityRetrievalStrategy.php')
-rw-r--r-- | Acl/Domain/ObjectIdentityRetrievalStrategy.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Acl/Domain/ObjectIdentityRetrievalStrategy.php b/Acl/Domain/ObjectIdentityRetrievalStrategy.php new file mode 100644 index 0000000..64315bf --- /dev/null +++ b/Acl/Domain/ObjectIdentityRetrievalStrategy.php @@ -0,0 +1,35 @@ +<?php + +namespace Symfony\Component\Security\Acl\Domain; + +use Symfony\Component\Security\Acl\Exception\InvalidDomainObjectException; +use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface; + +/* + * This file is part of the Symfony framework. + * + * (c) Fabien Potencier <fabien.potencier@symfony-project.com> + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * Strategy to be used for retrieving object identities from domain objects + * + * @author Johannes M. Schmitt <schmittjoh@gmail.com> + */ +class ObjectIdentityRetrievalStrategy implements ObjectIdentityRetrievalStrategyInterface +{ + /** + * {@inheritDoc} + */ + public function getObjectIdentity($domainObject) + { + try { + return ObjectIdentity::fromDomainObject($domainObject); + } catch (InvalidDomainObjectException $failed) { + return null; + } + } +}
\ No newline at end of file |