当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassMetadata::mapChild方法代码示例

本文整理汇总了PHP中Doctrine\Common\Persistence\Mapping\ClassMetadata::mapChild方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::mapChild方法的具体用法?PHP ClassMetadata::mapChild怎么用?PHP ClassMetadata::mapChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\Persistence\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::mapChild方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $class)
 {
     $element = $this->getElement($className);
     if (!$element) {
         return;
     }
     $element['type'] = isset($element['type']) ? $element['type'] : 'document';
     if ($element['type'] == 'document') {
         if (isset($element['repositoryClass'])) {
             $class->setCustomRepositoryClassName($element['repositoryClass']);
         }
         if (isset($element['versionable']) && $element['versionable']) {
             $class->setVersioned($element['versionable']);
         }
         $class->setNodeType(isset($element['nodeType']) ? $element['nodeType'] : 'nt:unstructured');
     } elseif ($element['type'] === 'mappedSuperclass') {
         $class->isMappedSuperclass = true;
     }
     if (isset($element['fields'])) {
         foreach ($element['fields'] as $fieldName => $mapping) {
             if (is_string($mapping)) {
                 $type = $mapping;
                 $mapping = array();
                 $mapping['type'] = $type;
             }
             if (!isset($mapping['fieldName'])) {
                 $mapping['fieldName'] = $fieldName;
             }
             $class->mapField($mapping);
         }
     }
     if (isset($element['id'])) {
         $mapping = array('fieldName' => $element['id'], 'id' => true);
         if (isset($element['id']['generator']['strategy'])) {
             $mapping['strategy'] = $element['id']['generator']['strategy'];
         }
         $class->mapId($mapping);
     }
     if (isset($element['node'])) {
         $class->mapNode(array('fieldName' => $element['node']));
     }
     if (isset($element['nodename'])) {
         $class->mapNodename(array('fieldName' => $element['nodename']));
     }
     if (isset($element['parentdocument'])) {
         $class->mapParentDocument(array('fieldName' => $element['parentdocument']));
     }
     if (isset($element['child'])) {
         foreach ($element['child'] as $fieldName => $mapping) {
             if (is_string($mapping)) {
                 $name = $mapping;
                 $mapping = array();
                 $mapping['name'] = $name;
             }
             if (!isset($mapping['fieldName'])) {
                 $mapping['fieldName'] = $fieldName;
             }
             $class->mapChild($mapping);
         }
     }
     if (isset($element['children'])) {
         foreach ($element['children'] as $fieldName => $mapping) {
             if (is_string($mapping)) {
                 $filter = $mapping;
                 $mapping = array();
                 $mapping['filter'] = $filter;
             }
             if (!isset($mapping['fieldName'])) {
                 $mapping['fieldName'] = $fieldName;
             }
             $class->mapChildren($mapping);
         }
     }
     if (isset($element['referenceOne'])) {
         foreach ($element['referenceOne'] as $fieldName => $reference) {
             $this->addMappingFromReference($class, $fieldName, $reference, 'one');
         }
     }
     if (isset($element['referenceMany'])) {
         foreach ($element['referenceMany'] as $fieldName => $reference) {
             $this->addMappingFromReference($class, $fieldName, $reference, 'many');
         }
     }
     // TODO: referrers, locale
     if (isset($element['versionName'])) {
         $class->mapVersionName(array('fieldName' => $element['versionName']));
     }
     if (isset($element['versionCreated'])) {
         $class->mapVersionCreated(array('fieldName' => $element['versionCreated']));
     }
     if (isset($element['lifecycleCallbacks'])) {
         foreach ($element['lifecycleCallbacks'] as $type => $methods) {
             foreach ($methods as $method) {
                 $class->addLifecycleCallback($method, constant('Doctrine\\ODM\\PHPCR\\Event::' . $type));
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:richardmiller,项目名称:phpcr-odm,代码行数:101,代码来源:YamlDriver.php

示例2: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $metadata)
 {
     /** @var $metadata \Doctrine\ODM\PHPCR\Mapping\ClassMetadata */
     $reflClass = $metadata->getReflectionClass();
     $documentAnnots = array();
     foreach ($this->reader->getClassAnnotations($reflClass) as $annot) {
         foreach ($this->entityAnnotationClasses as $annotClass => $i) {
             if ($annot instanceof $annotClass) {
                 $documentAnnots[$i] = $annot;
             }
         }
     }
     if (!$documentAnnots) {
         throw MappingException::classIsNotAValidDocument($className);
     }
     // find the winning document annotation
     ksort($documentAnnots);
     $documentAnnot = reset($documentAnnots);
     if ($documentAnnot instanceof ODM\MappedSuperclass) {
         $metadata->isMappedSuperclass = true;
     }
     if (null !== $documentAnnot->referenceable) {
         $metadata->setReferenceable($documentAnnot->referenceable);
     }
     if (null !== $documentAnnot->versionable) {
         $metadata->setVersioned($documentAnnot->versionable);
     }
     if (null !== $documentAnnot->mixins) {
         $metadata->setMixins($documentAnnot->mixins);
     }
     if (null !== $documentAnnot->inheritMixins) {
         $metadata->setInheritMixins($documentAnnot->inheritMixins);
     }
     if (null !== $documentAnnot->nodeType) {
         $metadata->setNodeType($documentAnnot->nodeType);
     }
     if (null !== $documentAnnot->repositoryClass) {
         $metadata->setCustomRepositoryClassName($documentAnnot->repositoryClass);
     }
     if (null !== $documentAnnot->translator) {
         $metadata->setTranslator($documentAnnot->translator);
     }
     foreach ($reflClass->getProperties() as $property) {
         if ($metadata->isInheritedField($property->name) && $metadata->name !== $property->getDeclaringClass()->getName()) {
             continue;
         }
         $mapping = array();
         $mapping['fieldName'] = $property->getName();
         foreach ($this->reader->getPropertyAnnotations($property) as $fieldAnnot) {
             if ($fieldAnnot instanceof ODM\Property) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapField($mapping);
             } elseif ($fieldAnnot instanceof ODM\Id) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapId($mapping);
             } elseif ($fieldAnnot instanceof ODM\Node) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapNode($mapping);
             } elseif ($fieldAnnot instanceof ODM\Nodename) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapNodename($mapping);
             } elseif ($fieldAnnot instanceof ODM\ParentDocument) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                 $metadata->mapParentDocument($mapping);
             } elseif ($fieldAnnot instanceof ODM\Child) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                 $metadata->mapChild($mapping);
             } elseif ($fieldAnnot instanceof ODM\Children) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                 $metadata->mapChildren($mapping);
             } elseif ($fieldAnnot instanceof ODM\ReferenceOne) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                 $metadata->mapManyToOne($mapping);
             } elseif ($fieldAnnot instanceof ODM\ReferenceMany) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                 $metadata->mapManyToMany($mapping);
             } elseif ($fieldAnnot instanceof ODM\Referrers) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                 $metadata->mapReferrers($mapping);
             } elseif ($fieldAnnot instanceof ODM\MixedReferrers) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapMixedReferrers($mapping);
             } elseif ($fieldAnnot instanceof ODM\Locale) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapLocale($mapping);
             } elseif ($fieldAnnot instanceof ODM\Depth) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapDepth($mapping);
             } elseif ($fieldAnnot instanceof ODM\VersionName) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapVersionName($mapping);
//.........这里部分代码省略.........
开发者ID:pkdevbox,项目名称:phpcr-odm,代码行数:101,代码来源:AnnotationDriver.php

示例3: loadMetadataForClass


//.........这里部分代码省略.........
                 throw new MappingException("Missing fieldName property for id field");
             }
             $fieldName = $element['id']['fieldName'];
         } else {
             $fieldName = $element['id'];
         }
         $mapping = array('fieldName' => $fieldName, 'id' => true);
         if (isset($element['id']['generator']['strategy'])) {
             $mapping['strategy'] = $element['id']['generator']['strategy'];
         }
         $class->mapId($mapping);
     }
     if (isset($element['node'])) {
         $class->mapNode(array('fieldName' => $element['node']));
     }
     if (isset($element['nodename'])) {
         $class->mapNodename(array('fieldName' => $element['nodename']));
     }
     if (isset($element['parentdocument'])) {
         $mapping = array('fieldName' => $element['parentdocument'], 'cascade' => isset($element['cascade']) ? $this->getCascadeMode($element['cascade']) : 0);
         $class->mapParentDocument($mapping);
     }
     if (isset($element['child'])) {
         foreach ($element['child'] as $fieldName => $mapping) {
             if (is_string($mapping)) {
                 $name = $mapping;
                 $mapping = array();
                 $mapping['nodeName'] = $name;
             }
             if (!isset($mapping['fieldName'])) {
                 $mapping['fieldName'] = $fieldName;
             }
             $mapping['cascade'] = isset($mapping['cascade']) ? $this->getCascadeMode($mapping['cascade']) : 0;
             $class->mapChild($mapping);
         }
     }
     if (isset($element['children'])) {
         foreach ($element['children'] as $fieldName => $mapping) {
             // TODO should we really support this syntax?
             if (is_string($mapping)) {
                 $filter = $mapping;
                 $mapping = array();
                 $mapping['filter'] = $filter;
             }
             if (!isset($mapping['fieldName'])) {
                 $mapping['fieldName'] = $fieldName;
             }
             if (!isset($mapping['filter'])) {
                 $mapping['filter'] = null;
             } elseif (is_string($mapping['filter'])) {
                 $mapping['filter'] = (array) $mapping['filter'];
             }
             if (!isset($mapping['fetchDepth'])) {
                 $mapping['fetchDepth'] = -1;
             }
             if (!isset($mapping['ignoreUntranslated'])) {
                 $mapping['ignoreUntranslated'] = false;
             }
             $mapping['cascade'] = isset($mapping['cascade']) ? $this->getCascadeMode($mapping['cascade']) : 0;
             $class->mapChildren($mapping);
         }
     }
     if (isset($element['referenceOne'])) {
         foreach ($element['referenceOne'] as $fieldName => $reference) {
             $this->addMappingFromReference($class, $fieldName, $reference, 'one');
         }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:67,代码来源:YamlDriver.php

示例4: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $class)
 {
     $xmlRoot = $this->getElement($className);
     if (!$xmlRoot) {
         return;
     }
     if ($xmlRoot->getName() == 'document') {
         if (isset($xmlRoot['repository-class'])) {
             $class->setCustomRepositoryClassName((string) $xmlRoot['repository-class']);
         }
         if (isset($xmlRoot['versionable']) && $xmlRoot['versionable'] !== 'false') {
             $class->setVersioned($xmlRoot['versionable']);
         }
         $class->setNodeType(isset($xmlRoot['nodeType']) ? (string) $xmlRoot['nodeType'] : 'nt:unstructured');
     } elseif ($xmlRoot->getName() === 'mapped-superclass') {
         $class->isMappedSuperclass = true;
     }
     if (isset($xmlRoot->field)) {
         foreach ($xmlRoot->field as $field) {
             $mapping = array();
             $attributes = $field->attributes();
             foreach ($attributes as $key => $value) {
                 $mapping[$key] = (string) $value;
                 // convert bool fields
                 if ($key === 'id' || $key === 'multivalue') {
                     $mapping[$key] = 'true' === $mapping[$key] ? true : false;
                 }
             }
             $class->mapField($mapping);
         }
     }
     if (isset($xmlRoot->id)) {
         $class->mapId(array('fieldName' => (string) $xmlRoot->id->attributes()->name, 'id' => true));
     }
     if (isset($xmlRoot->node)) {
         $class->mapNode(array('fieldName' => (string) $xmlRoot->node->attributes()->name));
     }
     if (isset($xmlRoot->nodename)) {
         $class->mapNodename(array('fieldName' => (string) $xmlRoot->nodename->attributes()->name));
     }
     if (isset($xmlRoot->parentdocument)) {
         $class->mapParentDocument(array('fieldName' => (string) $xmlRoot->parentdocument->attributes()->name));
     }
     if (isset($xmlRoot->child)) {
         foreach ($xmlRoot->child as $child) {
             $attributes = $child->attributes();
             $mapping = array('fieldName' => (string) $attributes->fieldName);
             if (isset($attributes['name'])) {
                 $mapping['name'] = (string) $attributes->name;
             }
             $class->mapChild($mapping);
         }
     }
     if (isset($xmlRoot->children)) {
         foreach ($xmlRoot->children as $children) {
             $attributes = $children->attributes();
             $mapping = array('fieldName' => (string) $attributes->fieldName);
             if (isset($attributes['filter'])) {
                 $mapping['filter'] = (string) $attributes->filter;
             }
             $class->mapChildren($mapping);
         }
     }
     if (isset($xmlRoot->{'reference-many'})) {
         foreach ($xmlRoot->{'reference-many'} as $reference) {
             $this->addReferenceMapping($class, $reference, 'many');
         }
     }
     if (isset($xmlRoot->{'reference-one'})) {
         foreach ($xmlRoot->{'reference-one'} as $reference) {
             $this->addReferenceMapping($class, $reference, 'one');
         }
     }
     // TODO: referrers, locale
     if (isset($xmlRoot->versionname)) {
         $class->mapVersionName(array('fieldName' => (string) $xmlRoot->versionname->attributes()->name));
     }
     if (isset($xmlRoot->versioncreated)) {
         $class->mapVersionCreated(array('fieldName' => (string) $xmlRoot->versionname->attributes()->name));
     }
     if (isset($xmlRoot->{'lifecycle-callbacks'})) {
         foreach ($xmlRoot->{'lifecycle-callbacks'}->{'lifecycle-callback'} as $lifecycleCallback) {
             $class->addLifecycleCallback((string) $lifecycleCallback['method'], constant('Doctrine\\ODM\\PHPCR\\Event::' . (string) $lifecycleCallback['type']));
         }
     }
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:89,代码来源:XmlDriver.php

示例5: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $metadata)
 {
     $reflClass = $metadata->getReflectionClass();
     $documentAnnots = array();
     foreach ($this->reader->getClassAnnotations($reflClass) as $annot) {
         foreach ($this->entityAnnotationClasses as $annotClass => $i) {
             if ($annot instanceof $annotClass) {
                 $documentAnnots[$i] = $annot;
             }
         }
     }
     if (!$documentAnnots) {
         throw MappingException::classIsNotAValidDocument($className);
     }
     // find the winning document annotation
     ksort($documentAnnots);
     $documentAnnot = reset($documentAnnots);
     if (isset($documentAnnot->versionable) && $documentAnnot->versionable) {
         $metadata->setVersioned($documentAnnot->versionable);
     }
     $metadata->setNodeType($documentAnnot->nodeType);
     if (isset($documentAnnot->referenceable) && $documentAnnot->referenceable) {
         $metadata->setReferenceable(true);
     }
     if ($documentAnnot->repositoryClass) {
         $metadata->setCustomRepositoryClassName($documentAnnot->repositoryClass);
     }
     if ($documentAnnot->translator) {
         $metadata->setTranslator($documentAnnot->translator);
     }
     foreach ($reflClass->getProperties() as $property) {
         if ($metadata->isMappedSuperclass && !$property->isPrivate() || $metadata->isInheritedField($property->name) && $metadata->name !== $property->getDeclaringClass()->getName()) {
             continue;
         }
         $mapping = array();
         $mapping['fieldName'] = $property->getName();
         foreach ($this->reader->getPropertyAnnotations($property) as $fieldAnnot) {
             if ($fieldAnnot instanceof ODM\Property) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapField($mapping);
             } elseif ($fieldAnnot instanceof ODM\Id) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapId($mapping);
             } elseif ($fieldAnnot instanceof ODM\Node) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapNode($mapping);
             } elseif ($fieldAnnot instanceof ODM\Nodename) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapNodename($mapping);
             } elseif ($fieldAnnot instanceof ODM\ParentDocument) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapParentDocument($mapping);
             } elseif ($fieldAnnot instanceof ODM\Child) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapChild($mapping);
             } elseif ($fieldAnnot instanceof ODM\Children) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapChildren($mapping);
             } elseif ($fieldAnnot instanceof ODM\ReferenceOne) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapManyToOne($mapping);
             } elseif ($fieldAnnot instanceof ODM\ReferenceMany) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapManyToMany($mapping);
             } elseif ($fieldAnnot instanceof ODM\Referrers) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapReferrers($mapping);
             } elseif ($fieldAnnot instanceof ODM\Locale) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapLocale($mapping);
             } elseif ($fieldAnnot instanceof ODM\VersionName) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapVersionName($mapping);
             } elseif ($fieldAnnot instanceof ODM\VersionCreated) {
                 $mapping = array_merge($mapping, (array) $fieldAnnot);
                 $metadata->mapVersionCreated($mapping);
             }
             if (!isset($mapping['name'])) {
                 $mapping['name'] = $property->getName();
             }
         }
     }
     foreach ($reflClass->getMethods() as $method) {
         if ($method->isPublic() && $method->getDeclaringClass()->getName() == $metadata->name) {
             foreach ($this->reader->getMethodAnnotations($method) as $annot) {
                 if ($annot instanceof ODM\PrePersist) {
                     $metadata->addLifecycleCallback($method->getName(), Event::prePersist);
                 } elseif ($annot instanceof ODM\PostPersist) {
                     $metadata->addLifecycleCallback($method->getName(), Event::postPersist);
                 } elseif ($annot instanceof ODM\PreUpdate) {
                     $metadata->addLifecycleCallback($method->getName(), Event::preUpdate);
                 } elseif ($annot instanceof ODM\PostUpdate) {
                     $metadata->addLifecycleCallback($method->getName(), Event::postUpdate);
                 } elseif ($annot instanceof ODM\PreRemove) {
                     $metadata->addLifecycleCallback($method->getName(), Event::preRemove);
                 } elseif ($annot instanceof ODM\PostRemove) {
                     $metadata->addLifecycleCallback($method->getName(), Event::postRemove);
//.........这里部分代码省略.........
开发者ID:nicam,项目名称:phpcr-odm,代码行数:101,代码来源:AnnotationDriver.php

示例6: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadata $class)
 {
     /** @var $class \Doctrine\ODM\PHPCR\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 (isset($xmlRoot['repository-class'])) {
         $class->setCustomRepositoryClassName((string) $xmlRoot['repository-class']);
     }
     if (isset($xmlRoot['translator'])) {
         $class->setTranslator((string) $xmlRoot['translator']);
     }
     if (isset($xmlRoot['versionable']) && $xmlRoot['versionable'] !== 'false') {
         $class->setVersioned(strtolower($xmlRoot['versionable']));
     }
     if (isset($xmlRoot['referenceable']) && $xmlRoot['referenceable'] !== 'false') {
         $class->setReferenceable((bool) $xmlRoot['referenceable']);
     }
     if (isset($xmlRoot->mixins)) {
         $mixins = array();
         foreach ($xmlRoot->mixins->mixin as $mixin) {
             $attributes = $mixin->attributes();
             if (!isset($attributes['type'])) {
                 throw new MappingException('<mixin> missing mandatory type attribute');
             }
             $mixins[] = (string) $attributes['type'];
         }
         $class->setMixins($mixins);
     }
     if (isset($xmlRoot['node-type'])) {
         $class->setNodeType((string) $xmlRoot['node-type']);
     }
     if ($xmlRoot->getName() === 'mapped-superclass') {
         $class->isMappedSuperclass = true;
     }
     if (isset($xmlRoot->field)) {
         foreach ($xmlRoot->field as $field) {
             $mapping = array();
             $attributes = $field->attributes();
             foreach ($attributes as $key => $value) {
                 $mapping[$key] = (string) $value;
                 // convert bool fields
                 if (in_array($key, array('id', 'multivalue', 'assoc', 'translated', 'nullable'))) {
                     $mapping[$key] = 'true' === $mapping[$key] ? true : false;
                 }
             }
             if (!isset($mapping['name'])) {
                 throw new MappingException(sprintf('Missing name attribute for field of %s', $className));
             }
             $mapping['fieldName'] = $mapping['name'];
             unset($mapping['name']);
             $class->mapField($mapping);
         }
     }
     if (isset($xmlRoot->id)) {
         $mapping = array('fieldName' => (string) $xmlRoot->id->attributes()->name, 'id' => true);
         if (isset($xmlRoot->id->generator) && isset($xmlRoot->id->generator->attributes()->strategy)) {
             $mapping['strategy'] = (string) $xmlRoot->id->generator->attributes()->strategy;
         }
         $class->mapId($mapping);
     }
     if (isset($xmlRoot->node)) {
         $class->mapNode(array('fieldName' => (string) $xmlRoot->node->attributes()->name));
     }
     if (isset($xmlRoot->nodename)) {
         $class->mapNodename(array('fieldName' => (string) $xmlRoot->nodename->attributes()->name));
     }
     if (isset($xmlRoot->{'parent-document'})) {
         $mapping = array('fieldName' => (string) $xmlRoot->{'parent-document'}->attributes()->name, 'cascade' => isset($xmlRoot->{'parent-document'}->cascade) ? $this->getCascadeMode($xmlRoot->{'parent-document'}->cascade) : 0);
         $class->mapParentDocument($mapping);
     }
     if (isset($xmlRoot->child)) {
         foreach ($xmlRoot->child as $child) {
             $attributes = $child->attributes();
             $mapping = array('fieldName' => (string) $attributes->name, 'cascade' => isset($child->cascade) ? $this->getCascadeMode($child->cascade) : 0);
             if (isset($attributes['node-name'])) {
                 $mapping['nodeName'] = (string) $attributes->{'node-name'};
             }
             $class->mapChild($mapping);
         }
     }
     if (isset($xmlRoot->children)) {
         foreach ($xmlRoot->children as $children) {
             $attributes = $children->attributes();
             $mapping = array('fieldName' => (string) $attributes->name, 'cascade' => isset($children->cascade) ? $this->getCascadeMode($children->cascade) : 0, 'filter' => isset($attributes['filter']) ? (array) $attributes->filter : null, 'fetchDepth' => isset($attributes['fetch-depth']) ? (int) $attributes->{'fetch-depth'} : -1, 'ignoreUntranslated' => !empty($attributes['ignore-untranslated']));
             $class->mapChildren($mapping);
         }
     }
     if (isset($xmlRoot->{'reference-many'})) {
         foreach ($xmlRoot->{'reference-many'} as $reference) {
             $attributes = $reference->attributes();
//.........这里部分代码省略.........
开发者ID:nikophil,项目名称:cmf-tests,代码行数:101,代码来源:XmlDriver.php


注:本文中的Doctrine\Common\Persistence\Mapping\ClassMetadata::mapChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。