Skip to content

Commit

Permalink
merged branch beberlei/Doctrine2.2Compatibilty (PR #3202)
Browse files Browse the repository at this point in the history
Commits
-------

c3f0ec7 Make DoctrineBundle fowards compatible with Doctrine 2.2

Discussion
----------

[DoctrineBundle] Doctrine 2.2 compatibilty

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes

Doctrine 2.2 does not initialize reflection anymore when in a code-generation context. This fails with the Symfony Metadata Factory that acceses the ReflectionClass after checking that the entity class_exists. This occurs when using code-generation in combination with the annotation driver.

This PR fixes the problem.
  • Loading branch information
fabpot committed Jan 28, 2012
2 parents 4ae41a5 + c3f0ec7 commit 47598c6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Symfony/Bundle/DoctrineBundle/Mapping/MetadataFactory.php
Expand Up @@ -75,8 +75,8 @@ public function getClassMetadata($class, $path = null)

$all = $metadata->getMetadata();
if (class_exists($class)) {
$r = $all[0]->getReflectionClass();
$path = $this->getBasePathForClass($class, $r->getNamespacename(), dirname($r->getFilename()));
$r = new \ReflectionClass($all[0]->name);
$path = $this->getBasePathForClass($class, $r->getNamespaceName(), dirname($r->getFilename()));
$metadata->setNamespace($r->getNamespacename());
} elseif (!$path) {
throw new \RuntimeException(sprintf('Unable to determine where to save the "%s" class (use the --path option).', $class));
Expand Down Expand Up @@ -104,8 +104,8 @@ public function getNamespaceMetadata($namespace, $path = null)

$all = $metadata->getMetadata();
if (class_exists($all[0]->name)) {
$r = $all[0]->getReflectionClass();
$path = $this->getBasePathForClass($namespace, $r->getNamespacename(), dirname($r->getFilename()));
$r = new \ReflectionClass($all[0]->name);
$path = $this->getBasePathForClass($namespace, $r->getNamespaceName(), dirname($r->getFilename()));
} elseif (!$path) {
throw new \RuntimeException(sprintf('Unable to determine where to save the "%s" class (use the --path option).', $all[0]->name));
}
Expand Down

0 comments on commit 47598c6

Please sign in to comment.