Skip to content

Commit d699405

Browse files
committed
Fix annotation metadata driver with Doctrine proxies
1 parent af68f44 commit d699405

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Mapping/Driver/AnnotationDriver.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Bazinga\GeocoderBundle\Mapping\ClassMetadata;
1717
use Bazinga\GeocoderBundle\Mapping\Exception;
1818
use Doctrine\Common\Annotations\Reader;
19+
use Doctrine\Persistence\Proxy;
1920

2021
/**
2122
* @author Markus Bachmann <[email protected]>
@@ -33,12 +34,21 @@ public function isGeocodeable($object): bool
3334
{
3435
$reflection = new \ReflectionObject($object);
3536

37+
if ($object instanceof Proxy) {
38+
$reflection = $reflection->getParentClass();
39+
}
40+
3641
return (bool) $this->reader->getClassAnnotation($reflection, Annotations\Geocodeable::class);
3742
}
3843

3944
public function loadMetadataFromObject($object)
4045
{
4146
$reflection = new \ReflectionObject($object);
47+
48+
if ($object instanceof Proxy) {
49+
$reflection = $reflection->getParentClass();
50+
}
51+
4252
if (!$annotation = $this->reader->getClassAnnotation($reflection, Annotations\Geocodeable::class)) {
4353
throw new Exception\MappingException(sprintf('The class %s is not geocodeable', get_class($object)));
4454
}

0 commit comments

Comments
 (0)