Skip to content
This repository
Browse code

Moved the check on mapped superclasses to an dedicated method

The previous logic was specific to the ORM and could not be reused for
the MongoDB ODM.
  • Loading branch information...
commit c6a01cc34ec3907a797cd89a3af56e07f4fee66e 1 parent d2f8a36
Christophe Coevoet stof authored
14 lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php
@@ -158,6 +158,16 @@ public function getAllMetadata()
158 158 abstract protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService);
159 159
160 160 /**
  161 + * Checks whether the class metadata is an entity.
  162 + *
  163 + * this method should
  164 + *
  165 + * @param ClassMetadata $class
  166 + * @return boolean
  167 + */
  168 + abstract protected function isEntity(ClassMetadata $class);
  169 +
  170 + /**
161 171 * Gets the class metadata descriptor for a class.
162 172 *
163 173 * @param string $className The name of the class.
@@ -278,7 +288,7 @@ protected function loadMetadata($name)
278 288 foreach ($parentClasses as $className) {
279 289 if (isset($this->loadedMetadata[$className])) {
280 290 $parent = $this->loadedMetadata[$className];
281   - if (isset($parent->isMappedSuperclass) && $parent->isMappedSuperclass === false) {
  291 + if ($this->isEntity($parent)) {
282 292 $rootEntityFound = true;
283 293 array_unshift($visited, $className);
284 294 }
@@ -294,7 +304,7 @@ protected function loadMetadata($name)
294 304
295 305 $parent = $class;
296 306
297   - if (isset($parent->isMappedSuperclass) && $class->isMappedSuperclass === false) {
  307 + if ($this->isEntity($class)) {
298 308 $rootEntityFound = true;
299 309 array_unshift($visited, $className);
300 310 }
5 tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php
@@ -121,6 +121,11 @@ protected function wakeupReflection(ClassMetadata $class, ReflectionService $ref
121 121 protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService)
122 122 {
123 123 }
  124 +
  125 + protected function isEntity(ClassMetadata $class)
  126 + {
  127 + return isset($class->isMappedSuperclass) && $class->isMappedSuperclass === false;
  128 + }
124 129 }
125 130
126 131 class RootEntity

0 comments on commit c6a01cc

Please sign in to comment.
Something went wrong with that request. Please try again.