Doctrine\OXM\Mapping\MappingException::duplicateXmlNameBinding PHP Метод

duplicateXmlNameBinding() публичный статический Метод

public static duplicateXmlNameBinding ( $className, $xmlName )
    public static function duplicateXmlNameBinding($className, $xmlName)
    {
        return new self("An xml mapping '{$xmlName}' already exists for the class '{$className}'");
    }

Usage Example

Пример #1
0
 /**
  * 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;
 }