Skip to content

Fix annotation metadata driver with Doctrine proxies #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Bazinga\GeocoderBundle\Mapping\ClassMetadata;
use Bazinga\GeocoderBundle\Mapping\Exception;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Util\ClassUtils;

/**
* @author Markus Bachmann <[email protected]>
Expand All @@ -31,14 +32,15 @@ public function __construct(Reader $reader)

public function isGeocodeable($object): bool
{
$reflection = new \ReflectionObject($object);
$reflection = ClassUtils::newReflectionObject($object);

return (bool) $this->reader->getClassAnnotation($reflection, Annotations\Geocodeable::class);
}

public function loadMetadataFromObject($object)
{
$reflection = new \ReflectionObject($object);
$reflection = ClassUtils::newReflectionObject($object);

if (!$annotation = $this->reader->getClassAnnotation($reflection, Annotations\Geocodeable::class)) {
throw new Exception\MappingException(sprintf('The class %s is not geocodeable', get_class($object)));
}
Expand Down