Since: 1.0
Author: Benjamin Eberlei (kontakt@beberlei.de)
Author: Lukas Kahwe Smith (smith@pooteeweet.org)
Inheritance: extends Exception
示例#1
0
 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $class)
 {
     /* @var $xmlRoot SimpleXMLElement */
     $xmlRoot = $this->getElement($className);
     if ($xmlRoot->getName() == "document") {
         $class->setCustomRepositoryClass(isset($xmlRoot['repository-class']) ? (string) $xmlRoot['repository-class'] : null);
         if (isset($xmlRoot['indexed']) && $xmlRoot['indexed'] == true) {
             $class->indexed = true;
         }
     } else {
         if ($xmlRoot->getName() == "embedded-document") {
             $class->isEmbeddedDocument = true;
         } else {
             if ($xmlRoot->getName() == "mapped-superclass") {
                 $class->isMappedSuperclass = true;
             } else {
                 throw MappingException::classIsNotAValidDocument($className);
             }
         }
     }
     // Evaluate <field ...> mappings
     if (isset($xmlRoot->field)) {
         foreach ($xmlRoot->field as $fieldMapping) {
             $class->mapField(array('fieldName' => (string) $fieldMapping['name'], 'jsonName' => isset($fieldMapping['json-name']) ? (string) $fieldMapping['json-name'] : null, 'indexed' => isset($fieldMapping['index']) ? (bool) $fieldMapping['index'] : false, 'type' => isset($fieldMapping['type']) ? (string) $fieldMapping['type'] : null, 'isVersionField' => isset($fieldMapping['version']) ? true : null));
         }
     }
     // Evaluate <id ..> mappings
     foreach ($xmlRoot->id as $idElement) {
         $class->mapField(array('fieldName' => (string) $idElement['name'], 'indexed' => isset($idElement['index']) ? (bool) $idElement['index'] : false, 'type' => isset($idElement['type']) ? (string) $idElement['type'] : null, 'id' => true, 'strategy' => isset($idElement['strategy']) ? (string) $idElement['strategy'] : null));
     }
     // Evaluate <many-to-one ..> mappings
     if (isset($xmlRoot->{"reference-one"})) {
         foreach ($xmlRoot->{"reference-one"} as $referenceOneElement) {
             $class->mapManyToOne(array('cascade' => isset($referenceManyElement->cascade) ? $this->getCascadeMode($referenceManyElement->cascade) : 0, 'targetDocument' => (string) $referenceOneElement['target-document'], 'fieldName' => (string) $referenceOneElement['field'], 'jsonName' => isset($referenceOneElement['json-name']) ? (string) $referenceOneElement['json-name'] : null));
         }
     }
     // Evaluate <many-to-one ..> mappings
     if (isset($xmlRoot->{"reference-many"})) {
         foreach ($xmlRoot->{"reference-many"} as $referenceManyElement) {
             $class->mapManyToMany(array('cascade' => isset($referenceManyElement->cascade) ? $this->getCascadeMode($referenceManyElement->cascade) : 0, 'targetDocument' => (string) $referenceManyElement['target-document'], 'fieldName' => (string) $referenceManyElement['field'], 'jsonName' => isset($referenceManyElement['json-name']) ? (string) $referenceManyElement['json-name'] : null, 'mappedBy' => isset($referenceManyElement['mapped-by']) ? (string) $referenceManyElement['mapped-by'] : null));
         }
     }
     // Evaluate <attachments ..> mapping
     if (isset($xmlRoot->{"attachments"})) {
         $class->mapAttachments((string) $xmlRoot->{"attachments"}[0]['field']);
     }
     // Evaluate <embed-one />
     if (isset($xmlRoot->{'embed-one'})) {
         foreach ($xmlRoot->{'embed-one'} as $embedOneElement) {
             $class->mapEmbedded(array('targetDocument' => (string) $embedOneElement['target-document'], 'fieldName' => (string) $embedOneElement['field'], 'jsonName' => isset($embedOneElement['json-name']) ? (string) $embedOneElement['json-name'] : null, 'embedded' => 'one'));
         }
     }
     // Evaluate <embed-many />
     if (isset($xmlRoot->{'embed-many'})) {
         foreach ($xmlRoot->{'embed-many'} as $embedManyElement) {
             $class->mapEmbedded(array('targetDocument' => (string) $embedManyElement['target-document'], 'fieldName' => (string) $embedManyElement['field'], 'jsonName' => isset($embedManyElement['json-name']) ? (string) $embedManyElement['json-name'] : null, 'embedded' => 'many'));
         }
     }
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $class)
 {
     foreach ($this->drivers as $namespace => $driver) {
         if (strpos($className, $namespace) === 0) {
             $driver->loadMetadataForClass($className, $class);
             return;
         }
     }
     throw MappingException::classIsNotAValidDocument($className);
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $class)
 {
     $element = $this->getElement($className);
     if ($element['type'] == 'document') {
         $class->setCustomRepositoryClass(isset($element['repositoryClass']) ? $element['repositoryClass'] : null);
         if (isset($element['indexed']) && $element['indexed'] == true) {
             $class->indexed = true;
         }
     } else {
         if ($element['type'] == 'embedded') {
             $class->isEmbeddedDocument = true;
         } else {
             if (strtolower($element['type']) == "mappedsuperclass") {
                 $class->isMappedSuperclass = true;
             } else {
                 throw MappingException::classIsNotAValidDocument($className);
             }
         }
     }
     if (isset($element['id'])) {
         foreach ($element['id'] as $fieldName => $idElement) {
             $class->mapField(array('fieldName' => $fieldName, 'indexed' => isset($idElement['indexed']) ? (bool) $idElement['indexed'] : false, 'type' => isset($idElement['type']) ? $idElement['type'] : null, 'id' => true, 'strategy' => isset($idElement['strategy']) ? $idElement['strategy'] : null));
         }
     }
     if (isset($element['fields'])) {
         foreach ($element['fields'] as $fieldName => $fieldElement) {
             $class->mapField(array('fieldName' => $fieldName, 'jsonName' => isset($fieldElement['jsonName']) ? $fieldElement['jsonName'] : null, 'indexed' => isset($fieldElement['indexed']) ? (bool) $fieldElement['indexed'] : false, 'type' => isset($fieldElement['type']) ? $fieldElement['type'] : null, 'isVersionField' => isset($fieldElement['version']) ? true : null));
         }
     }
     if (isset($element['referenceOne'])) {
         foreach ($element['referenceOne'] as $field => $referenceOneElement) {
             $class->mapManyToOne(array('cascade' => isset($referenceManyElement->cascade) ? $this->getCascadeMode($referenceManyElement->cascade) : 0, 'targetDocument' => (string) $referenceOneElement['targetDocument'], 'fieldName' => $field, 'jsonName' => isset($referenceOneElement['jsonName']) ? (string) $referenceOneElement['jsonName'] : null));
         }
     }
     if (isset($element['referenceMany'])) {
         foreach ($element['referenceMany'] as $field => $referenceManyElement) {
             $class->mapManyToMany(array('cascade' => isset($referenceManyElement->cascade) ? $this->getCascadeMode($referenceManyElement->cascade) : 0, 'targetDocument' => (string) $referenceManyElement['targetDocument'], 'fieldName' => $field, 'jsonName' => isset($referenceManyElement['jsonName']) ? (string) $referenceManyElement['jsonName'] : null, 'mappedBy' => isset($referenceManyElement['mappedBy']) ? (string) $referenceManyElement['mappedBy'] : null));
         }
     }
     if (isset($element['attachments'])) {
         $class->mapAttachments($element['attachments']);
     }
     if (isset($element['embedOne'])) {
         foreach ($element['embedOne'] as $field => $embedOneElement) {
             $class->mapEmbedded(array('targetDocument' => (string) $embedOneElement['targetDocument'], 'fieldName' => $field, 'jsonName' => isset($embedOneElement['jsonName']) ? (string) $embedOneElement['jsonName'] : null, 'embedded' => 'one'));
         }
     }
     if (isset($element['embedMany'])) {
         foreach ($element['embedMany'] as $field => $embedManyElement) {
             $class->mapEmbedded(array('targetDocument' => (string) $embedManyElement['targetDocument'], 'fieldName' => $field, 'jsonName' => isset($embedManyElement['jsonName']) ? (string) $embedManyElement['jsonName'] : null, 'embedded' => 'many'));
         }
     }
 }
 protected function _findMappingFile($className)
 {
     $defaultFileName = str_replace('\\', '.', $className) . $this->fileExtension;
     foreach ($this->paths as $path) {
         if (!isset($this->prefixes[$path])) {
             if (file_exists($path . DIRECTORY_SEPARATOR . $defaultFileName)) {
                 return $path . DIRECTORY_SEPARATOR . $defaultFileName;
             }
             continue;
         }
         $prefix = $this->prefixes[$path];
         if (0 !== strpos($className, $prefix . '\\')) {
             continue;
         }
         $filename = $path . '/' . strtr(substr($className, strlen($prefix) + 1), '\\', '.') . $this->fileExtension;
         if (file_exists($filename)) {
             return $filename;
         }
         throw MappingException::mappingFileNotFound($className, $filename);
     }
     throw MappingException::mappingFileNotFound($className, substr($className, strrpos($className, '\\') + 1) . $this->fileExtension);
 }
示例#5
0
 /**
  * {@inheritDoc}
  */
 public function getAllClassNames()
 {
     if ($this->classNames !== null) {
         return $this->classNames;
     }
     if (!$this->paths) {
         throw MappingException::pathRequired();
     }
     $classes = array();
     $includedFiles = array();
     foreach ($this->paths as $path) {
         if (!is_dir($path)) {
             throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath();
         }
         $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
         foreach ($iterator as $file) {
             if (($fileName = $file->getBasename($this->fileExtension)) == $file->getBasename()) {
                 continue;
             }
             $sourceFile = realpath($file->getPathName());
             require_once $sourceFile;
             $includedFiles[] = $sourceFile;
         }
     }
     $declared = get_declared_classes();
     foreach ($declared as $className) {
         $rc = new \ReflectionClass($className);
         $sourceFile = $rc->getFileName();
         if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) {
             $classes[] = $className;
         }
     }
     $this->classNames = $classes;
     return $classes;
 }
示例#6
0
 public function markInheritanceRoot()
 {
     if ($this->parentClasses) {
         throw MappingException::invalidInheritanceRoot($this->name, $this->parentClasses);
     }
     $this->inInheritanceHierachy = true;
 }
示例#7
0
 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $class)
 {
     /** @var $class \Doctrine\ODM\CouchDB\Mapping\ClassMetadata */
     try {
         $element = $this->getElement($className);
     } catch (DoctrineMappingException $e) {
         // Convert Exception type for consistency with other drivers
         throw new MappingException($e->getMessage(), $e->getCode(), $e);
     }
     if (!$element) {
         return;
     }
     if ($element['type'] == 'document') {
         $class->setCustomRepositoryClass(isset($element['repositoryClass']) ? $element['repositoryClass'] : null);
         if (isset($element['indexed']) && $element['indexed'] == true) {
             $class->indexed = true;
         }
         if (isset($element['inheritanceRoot']) && $element['inheritanceRoot']) {
             $class->markInheritanceRoot();
         }
     } else {
         if ($element['type'] == 'embedded') {
             $class->isEmbeddedDocument = true;
             if (isset($element['inheritanceRoot']) && $element['inheritanceRoot']) {
                 $class->markInheritanceRoot();
             }
         } else {
             if (strtolower($element['type']) == "mappedsuperclass") {
                 $class->isMappedSuperclass = true;
             } else {
                 throw MappingException::classIsNotAValidDocument($className);
             }
         }
     }
     if (isset($element['id'])) {
         foreach ($element['id'] as $fieldName => $idElement) {
             $class->mapField(array('fieldName' => $fieldName, 'indexed' => isset($idElement['index']) ? (bool) $idElement['index'] : false, 'type' => isset($idElement['type']) ? $idElement['type'] : null, 'id' => true, 'strategy' => isset($idElement['strategy']) ? $idElement['strategy'] : null));
         }
     }
     if (isset($element['fields'])) {
         foreach ($element['fields'] as $fieldName => $fieldElement) {
             $class->mapField(array('fieldName' => $fieldName, 'jsonName' => isset($fieldElement['jsonName']) ? $fieldElement['jsonName'] : null, 'indexed' => isset($fieldElement['index']) ? (bool) $fieldElement['index'] : false, 'type' => isset($fieldElement['type']) ? $fieldElement['type'] : null, 'isVersionField' => isset($fieldElement['version']) ? true : null));
         }
     }
     if (isset($element['referenceOne'])) {
         foreach ($element['referenceOne'] as $field => $referenceOneElement) {
             $class->mapManyToOne(array('cascade' => isset($referenceOneElement['cascade']) ? $this->getCascadeMode($referenceOneElement['cascade']) : 0, 'targetDocument' => (string) $referenceOneElement['targetDocument'], 'fieldName' => $field, 'jsonName' => isset($referenceOneElement['jsonName']) ? (string) $referenceOneElement['jsonName'] : null, 'indexed' => isset($referenceOneElement['index']) ? (bool) $referenceOneElement['index'] : false));
         }
     }
     if (isset($element['referenceMany'])) {
         foreach ($element['referenceMany'] as $field => $referenceManyElement) {
             $class->mapManyToMany(array('cascade' => isset($referenceManyElement['cascade']) ? $this->getCascadeMode($referenceManyElement['cascade']) : 0, 'targetDocument' => (string) $referenceManyElement['targetDocument'], 'fieldName' => $field, 'jsonName' => isset($referenceManyElement['jsonName']) ? (string) $referenceManyElement['jsonName'] : null, 'mappedBy' => isset($referenceManyElement['mappedBy']) ? (string) $referenceManyElement['mappedBy'] : null));
         }
     }
     if (isset($element['attachments'])) {
         $class->mapAttachments($element['attachments']);
     }
     if (isset($element['embedOne'])) {
         foreach ($element['embedOne'] as $field => $embedOneElement) {
             $class->mapEmbedded(array('targetDocument' => (string) $embedOneElement['targetDocument'], 'fieldName' => $field, 'jsonName' => isset($embedOneElement['jsonName']) ? (string) $embedOneElement['jsonName'] : null, 'embedded' => 'one'));
         }
     }
     if (isset($element['embedMany'])) {
         foreach ($element['embedMany'] as $field => $embedManyElement) {
             $class->mapEmbedded(array('targetDocument' => (string) $embedManyElement['targetDocument'], 'fieldName' => $field, 'jsonName' => isset($embedManyElement['jsonName']) ? (string) $embedManyElement['jsonName'] : null, 'embedded' => 'many'));
         }
     }
 }
 /**
  * Loads the metadata of the class in question and all it's ancestors whose metadata
  * is still not loaded.
  *
  * @param string $className The name of the class for which the metadata should get loaded.
  */
 private function loadMetadata($name)
 {
     if (!class_exists($name)) {
         throw MappingException::classNotFound($name);
     }
     $parentClasses = $this->getParentClasses($name);
     $parentClasses[] = $name;
     $loaded = array();
     $parent = null;
     /* @var $parent ClassMetadata */
     foreach ($parentClasses as $className) {
         if (isset($this->loadedMetadata[$className])) {
             $parent = $this->loadedMetadata[$className];
             continue;
         }
         // original class was checked above already
         if ($className != $name && !class_exists($className)) {
             throw MappingException::classNotFound($className);
         }
         if ($parent) {
             $class = $parent->deriveChildMetadata($className);
         } else {
             $class = new ClassMetadata($className);
         }
         $this->loadedMetadata[$className] = $class;
         $this->driver->loadMetadataForClass($className, $this->loadedMetadata[$className]);
         $parent = $class;
         $loaded[] = $className;
     }
     return $loaded;
 }
示例#9
0
 /**
  * Gets the names of all mapped classes known to this driver.
  * 
  * @return array The names of all mapped classes known to this driver.
  */
 public function getAllClassNames()
 {
     $classes = array();
     if ($this->paths) {
         foreach ((array) $this->paths as $path) {
             if (!is_dir($path)) {
                 throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath();
             }
             $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
             foreach ($iterator as $file) {
                 if (($fileName = $file->getBasename($this->fileExtension)) == $file->getBasename()) {
                     continue;
                 }
                 // NOTE: All files found here means classes are not transient!
                 $classes[] = str_replace('.', '\\', $fileName);
             }
         }
     }
     return $classes;
 }
示例#10
0
 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $class)
 {
     $reflClass = $class->getReflectionClass();
     $isValidDocument = false;
     $classAnnotations = $this->reader->getClassAnnotations($reflClass);
     foreach ($classAnnotations as $classAnnotation) {
         if ($classAnnotation instanceof ODM\Document) {
             if ($classAnnotation->indexed) {
                 $class->indexed = true;
             }
             $class->setCustomRepositoryClass($classAnnotation->repositoryClass);
             $isValidDocument = true;
         } elseif ($classAnnotation instanceof ODM\EmbeddedDocument) {
             $class->isEmbeddedDocument = true;
             $isValidDocument = true;
         } else {
             if ($classAnnotation instanceof ODM\MappedSuperclass) {
                 $class->isMappedSuperclass = true;
                 $isValidDocument = true;
             } else {
                 if ($classAnnotation instanceof ODM\Index) {
                     $class->indexed = true;
                 } else {
                     if ($classAnnotation instanceof ODM\InheritanceRoot) {
                         $class->markInheritanceRoot();
                     }
                 }
             }
         }
     }
     if (!$isValidDocument) {
         throw MappingException::classIsNotAValidDocument($className);
     }
     foreach ($reflClass->getProperties() as $property) {
         if ($class->isInheritedAssociation($property->name) || $class->isInheritedField($property->name)) {
             continue;
         }
         $mapping = array();
         $mapping['fieldName'] = $property->name;
         if ($this->reader->getPropertyAnnotation($property, 'Doctrine\\ODM\\CouchDB\\Mapping\\Annotations\\Index')) {
             $mapping['indexed'] = true;
         }
         foreach ($this->reader->getPropertyAnnotations($property) as $fieldAnnot) {
             if ($fieldAnnot instanceof \Doctrine\ODM\CouchDB\Mapping\Annotations\Field) {
                 if ($fieldAnnot instanceof \Doctrine\ODM\CouchDB\Mapping\Annotations\Version) {
                     $mapping['isVersionField'] = true;
                 }
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 unset($mapping['value']);
                 $class->mapField($mapping);
             } else {
                 if ($fieldAnnot instanceof \Doctrine\ODM\CouchDB\Mapping\Annotations\ReferenceOne) {
                     $mapping = array_merge($mapping, (array) $fieldAnnot);
                     $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                     unset($mapping['value']);
                     $class->mapManyToOne($mapping);
                 } else {
                     if ($fieldAnnot instanceof \Doctrine\ODM\CouchDB\Mapping\Annotations\ReferenceMany) {
                         $mapping = array_merge($mapping, (array) $fieldAnnot);
                         $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                         unset($mapping['value']);
                         $class->mapManyToMany($mapping);
                     } else {
                         if ($fieldAnnot instanceof \Doctrine\ODM\CouchDB\Mapping\Annotations\Attachments) {
                             $class->mapAttachments($mapping['fieldName']);
                         } else {
                             if ($fieldAnnot instanceof \Doctrine\ODM\CouchDB\Mapping\Annotations\EmbedOne || $fieldAnnot instanceof \Doctrine\ODM\CouchDB\Mapping\Annotations\EmbedMany) {
                                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                                 unset($mapping['value']);
                                 $class->mapEmbedded($mapping);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
示例#11
0
 /**
  * Gets the mapping of a field.
  *
  * @param string $fieldName  The field name.
  * @return array  The field mapping.
  */
 public function getFieldMapping($fieldName)
 {
     if (!isset($this->fieldMappings[$fieldName])) {
         throw MappingException::mappingNotFound($this->name, $fieldName);
     }
     return $this->fieldMappings[$fieldName];
 }
示例#12
0
 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $class)
 {
     /** @var $class \Doctrine\ODM\CouchDB\Mapping\ClassMetadata */
     try {
         $xmlRoot = $this->getElement($className);
     } catch (DoctrineMappingException $e) {
         // Convert Exception type for consistency with other drivers
         throw new MappingException($e->getMessage(), $e->getCode(), $e);
     }
     if (!$xmlRoot) {
         return;
     }
     if ($xmlRoot->getName() == 'document') {
         $class->setCustomRepositoryClass(isset($xmlRoot['repository-class']) ? (string) $xmlRoot['repository-class'] : null);
         if (isset($xmlRoot['indexed']) && $xmlRoot['indexed'] == true) {
             $class->indexed = true;
         }
         if (isset($xmlRoot['inheritance-root']) && $xmlRoot['inheritance-root']) {
             $class->markInheritanceRoot();
         }
     } else {
         if ($xmlRoot->getName() == "embedded-document") {
             $class->isEmbeddedDocument = true;
             if (isset($xmlRoot['inheritance-root']) && $xmlRoot['inheritance-root']) {
                 $class->markInheritanceRoot();
             }
         } else {
             if ($xmlRoot->getName() == "mapped-superclass") {
                 $class->isMappedSuperclass = true;
             } else {
                 throw MappingException::classIsNotAValidDocument($className);
             }
         }
     }
     // Evaluate <field ...> mappings
     if (isset($xmlRoot->field)) {
         foreach ($xmlRoot->field as $fieldMapping) {
             $class->mapField(array('fieldName' => (string) $fieldMapping['name'], 'jsonName' => isset($fieldMapping['json-name']) ? (string) $fieldMapping['json-name'] : null, 'indexed' => isset($fieldMapping['index']) ? (bool) $fieldMapping['index'] : false, 'type' => isset($fieldMapping['type']) ? (string) $fieldMapping['type'] : null, 'isVersionField' => isset($fieldMapping['version']) ? true : null));
         }
     }
     // Evaluate <id ..> mappings
     foreach ($xmlRoot->id as $idElement) {
         $class->mapField(array('fieldName' => (string) $idElement['name'], 'indexed' => isset($idElement['index']) ? (bool) $idElement['index'] : false, 'type' => isset($idElement['type']) ? (string) $idElement['type'] : null, 'id' => true, 'strategy' => isset($idElement['strategy']) ? (string) $idElement['strategy'] : null));
     }
     // Evaluate <version ..> mappings
     foreach ($xmlRoot->version as $versionElement) {
         $class->mapField(array('fieldName' => (string) $versionElement['name'], 'type' => 'string', 'isVersionField' => true, 'jsonName' => '_rev'));
     }
     // Evaluate <many-to-one ..> mappings
     if (isset($xmlRoot->{"reference-one"})) {
         foreach ($xmlRoot->{"reference-one"} as $referenceOneElement) {
             $class->mapManyToOne(array('cascade' => isset($referenceOneElement->cascade) ? $this->getCascadeMode($referenceOneElement->cascade) : 0, 'targetDocument' => (string) $referenceOneElement['target-document'], 'fieldName' => (string) $referenceOneElement['field'], 'jsonName' => isset($referenceOneElement['json-name']) ? (string) $referenceOneElement['json-name'] : null, 'indexed' => isset($referenceOneElement['index']) ? (bool) $referenceOneElement['index'] : false));
         }
     }
     // Evaluate <many-to-one ..> mappings
     if (isset($xmlRoot->{"reference-many"})) {
         foreach ($xmlRoot->{"reference-many"} as $referenceManyElement) {
             $class->mapManyToMany(array('cascade' => isset($referenceManyElement->cascade) ? $this->getCascadeMode($referenceManyElement->cascade) : 0, 'targetDocument' => (string) $referenceManyElement['target-document'], 'fieldName' => (string) $referenceManyElement['field'], 'jsonName' => isset($referenceManyElement['json-name']) ? (string) $referenceManyElement['json-name'] : null, 'mappedBy' => isset($referenceManyElement['mapped-by']) ? (string) $referenceManyElement['mapped-by'] : null));
         }
     }
     // Evaluate <attachments ..> mapping
     if (isset($xmlRoot->{"attachments"})) {
         $class->mapAttachments((string) $xmlRoot->{"attachments"}[0]['field']);
     }
     // Evaluate <embed-one />
     if (isset($xmlRoot->{'embed-one'})) {
         foreach ($xmlRoot->{'embed-one'} as $embedOneElement) {
             $class->mapEmbedded(array('targetDocument' => (string) $embedOneElement['target-document'], 'fieldName' => (string) $embedOneElement['field'], 'jsonName' => isset($embedOneElement['json-name']) ? (string) $embedOneElement['json-name'] : null, 'embedded' => 'one'));
         }
     }
     // Evaluate <embed-many />
     if (isset($xmlRoot->{'embed-many'})) {
         foreach ($xmlRoot->{'embed-many'} as $embedManyElement) {
             $class->mapEmbedded(array('targetDocument' => (string) $embedManyElement['target-document'], 'fieldName' => (string) $embedManyElement['field'], 'jsonName' => isset($embedManyElement['json-name']) ? (string) $embedManyElement['json-name'] : null, 'embedded' => 'many'));
         }
     }
 }
 /**
  * Loads the metadata of the class in question and all it's ancestors whose metadata
  * is still not loaded.
  *
  * @param string $className The name of the class for which the metadata should get loaded.
  * @return array
  * @throws MappingException
  */
 protected function loadMetadata($className)
 {
     if (class_exists($className)) {
         return parent::loadMetadata($className);
     }
     throw MappingException::classNotFound($className);
 }