diff options
Diffstat (limited to 'Acl/Domain/ObjectIdentity.php')
-rw-r--r-- | Acl/Domain/ObjectIdentity.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Acl/Domain/ObjectIdentity.php b/Acl/Domain/ObjectIdentity.php index 0de7fdd..57a17f8 100644 --- a/Acl/Domain/ObjectIdentity.php +++ b/Acl/Domain/ObjectIdentity.php @@ -58,10 +58,14 @@ class ObjectIdentity implements ObjectIdentityInterface throw new InvalidDomainObjectException('$domainObject must be an object.'); } - if ($domainObject instanceof DomainObjectInterface) { - return new self($domainObject->getObjectIdentifier(), get_class($domainObject)); - } else if (method_exists($domainObject, 'getId')) { - return new self($domainObject->getId(), get_class($domainObject)); + try { + if ($domainObject instanceof DomainObjectInterface) { + return new self($domainObject->getObjectIdentifier(), get_class($domainObject)); + } else if (method_exists($domainObject, 'getId')) { + return new self($domainObject->getId(), get_class($domainObject)); + } + } catch (\InvalidArgumentException $invalid) { + throw new InvalidDomainObjectException($invalid->getMessage(), 0, $invalid); } throw new InvalidDomainObjectException('$domainObject must either implement the DomainObjectInterface, or have a method named "getId".'); |