Since: 2.0
Author: Richard Fullmer (richard.fullmer@opensoftdev.com)
 /**
  * {@inheritDoc}
  */
 protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents)
 {
     /* @var $class \Doctrine\OXM\Mapping\ClassMetadata */
     /* @var $parent \Doctrine\OXM\Mapping\ClassMetadata */
     if ($parent) {
         $class->setIdGeneratorType($parent->generatorType);
         $this->addInheritedFields($class, $parent);
         $class->setXmlNamespaces($parent->xmlNamespaces);
         $class->setIdentifier($parent->identifier);
         $class->setLifecycleCallbacks($parent->lifecycleCallbacks);
         $class->setChangeTrackingPolicy($parent->changeTrackingPolicy);
         $class->parent = $parent->getName();
     }
     // Invoke driver
     try {
         $this->driver->loadMetadataForClass($class->getName(), $class);
     } catch (ReflectionException $e) {
         throw MappingException::reflectionFailure($class->getName(), $e);
     }
     $xmlNamespace = empty($class->xmlNamespaces) ? '' : $class->xmlNamespaces[0]['url'];
     foreach ($class->xmlNamespaces as $namespaceData) {
         if (empty($namespaceData['prefix'])) {
             $xmlNamespace = $namespaceData['url'];
         }
     }
     $xmlName = $class->getXmlName();
     // Ignore duplicate binding issues -- at least for now
     /*
     if ( $this->isEntity($class) && array_key_exists($xmlName, $this->xmlToClassMap) && array_key_exists($xmlNamespace, $this->xmlToClassMap[$xmlName])) {
     			if ($this->xmlToClassMap[$xmlName][$xmlNamespace] == $class->getName() || $this->xmlToClassMap[$xmlName][$xmlNamespace] == '\\' . $class->getName()) {
     				// Ignore
     	        } else {
     		throw MappingException::duplicateXmlNameBinding($class->getName(), $class->getXmlName());
     	        }
     }
     */
     // The previous test should be sufficent for us to just assume that the namespace/alternative is fine
     if (!empty($parent)) {
         $this->alternativeClassMap[$parent->getName()][$xmlNamespace] = $class->getName();
     }
     if (!$class->isMappedSuperclass) {
         $this->xmlToClassMap[$xmlName][$xmlNamespace] = $class->getName();
     }
     if ($parent && !$parent->isMappedSuperclass) {
         if ($parent->generatorType) {
             $class->setIdGeneratorType($parent->generatorType);
         }
         if ($parent->idGenerator) {
             $class->setIdGenerator($parent->idGenerator);
         }
     } else {
         $this->completeIdGeneratorMapping($class);
     }
     $class->setParentClasses($nonSuperclassParents);
     // Todo - ensure that root elements have an ID mapped
     if ($this->evm->hasListeners(Events::loadClassMetadata)) {
         $eventArgs = new LoadClassMetadataEventArgs($class, $this);
         $this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
     }
 }
 /**
  * Loads the metadata of the class in question and all it's ancestors whose metadata
  * is still not loaded.
  *
  * @param string $name The name of the class for which the metadata should get loaded.
  * @param array  $tables The metadata collection to which the loaded metadata is added.
  */
 protected function loadMetadata($name)
 {
     if (!$this->initialized) {
         $this->initialize();
     }
     $loaded = array();
     $parentClasses = $this->getParentClasses($name);
     $parentClasses[] = $name;
     // Move down the hierarchy of parent classes, starting from the topmost class
     $parent = null;
     $visited = array();
     foreach ($parentClasses as $className) {
         if (isset($this->loadedMetadata[$className])) {
             $parent = $this->loadedMetadata[$className];
             if ($parent->isMappedSuperclass) {
                 array_unshift($visited, $className);
             }
             continue;
         }
         $class = $this->newClassMetadataInstance($className);
         if ($parent) {
             $class->setIdGeneratorType($parent->generatorType);
             $this->addInheritedFields($class, $parent);
             $class->setXmlNamespaces($parent->xmlNamespaces);
             $class->setIdentifier($parent->identifier);
             $class->setLifecycleCallbacks($parent->lifecycleCallbacks);
             $class->setChangeTrackingPolicy($parent->changeTrackingPolicy);
         }
         // Invoke driver
         try {
             $this->driver->loadMetadataForClass($className, $class);
         } catch (ReflectionException $e) {
             throw MappingException::reflectionFailure($className, $e);
         }
         if (!$class->isMappedSuperclass && in_array($class->getXmlName(), array_keys($this->xmlToClassMap))) {
             throw MappingException::duplicateXmlNameBinding($className, $class->getXmlName());
         }
         if ($parent && !$parent->isMappedSuperclass) {
             if ($parent->generatorType) {
                 $class->setIdGeneratorType($parent->generatorType);
             }
             if ($parent->idGenerator) {
                 $class->setIdGenerator($parent->idGenerator);
             }
         } else {
             $this->completeIdGeneratorMapping($class);
         }
         $class->setParentClasses($visited);
         // Todo - ensure that root elements have an ID mapped
         if ($this->evm->hasListeners(Events::loadClassMetadata)) {
             $eventArgs = new \Doctrine\OXM\Event\LoadClassMetadataEventArgs($class, $this);
             $this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
         }
         $this->loadedMetadata[$className] = $class;
         $this->completeMappingTypeValidation($className, $class);
         if (!$class->isMappedSuperclass) {
             $this->xmlToClassMap[$class->getXmlName()] = $className;
         }
         $parent = $class;
         if ($class->isMappedSuperclass) {
             array_unshift($visited, $className);
         }
         $loaded[] = $className;
     }
     return $loaded;
 }
Esempio n. 3
0
 /**
  * @param string $className
  * @return boolean
  */
 public function isTransient($className)
 {
     return $this->driver->isTransient($className);
 }