adds support for XML/Yaml drivers
This commit is contained in:
parent
9ad376c006
commit
fb3a06b9e7
@ -43,14 +43,14 @@ instead of simply adding the respective columns to the ``User`` class.
|
||||
|
||||
<doctrine-mapping>
|
||||
<entity name="User">
|
||||
<embedded class="Address" />
|
||||
<embedded name="address" class="Address" />
|
||||
</entity>
|
||||
|
||||
<embeddable name="Address">
|
||||
<column name="street" type="string" />
|
||||
<column name="postalCode" type="string" />
|
||||
<column name="city" type="string" />
|
||||
<column name="country" type="string" />
|
||||
<field name="street" type="string" />
|
||||
<field name="postalCode" type="string" />
|
||||
<field name="city" type="string" />
|
||||
<field name="country" type="string" />
|
||||
</embeddable>
|
||||
</doctrine-mapping>
|
||||
|
||||
@ -64,7 +64,7 @@ instead of simply adding the respective columns to the ``User`` class.
|
||||
|
||||
Address:
|
||||
type: embeddable
|
||||
columns:
|
||||
fields:
|
||||
street: { type: string }
|
||||
postalCode: { type: string }
|
||||
city: { type: string }
|
||||
|
@ -69,6 +69,8 @@ class XmlDriver extends FileDriver
|
||||
isset($xmlRoot['repository-class']) ? (string)$xmlRoot['repository-class'] : null
|
||||
);
|
||||
$metadata->isMappedSuperclass = true;
|
||||
} else if ($xmlRoot->getName() == 'embeddable') {
|
||||
$metadata->isEmbeddedClass = true;
|
||||
} else {
|
||||
throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className);
|
||||
}
|
||||
@ -241,6 +243,17 @@ class XmlDriver extends FileDriver
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($xmlRoot->embedded)) {
|
||||
foreach ($xmlRoot->embedded as $embeddedMapping) {
|
||||
$mapping = array(
|
||||
'fieldName' => (string) $embeddedMapping['name'],
|
||||
'class' => (string) $embeddedMapping['class'],
|
||||
'columnPrefix' => isset($embeddedMapping['class']) ? (string) $embeddedMapping['class'] : null,
|
||||
);
|
||||
$metadata->mapEmbedded($mapping);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($mappings as $mapping) {
|
||||
if (isset($mapping['version'])) {
|
||||
$metadata->setVersionMapping($mapping);
|
||||
|
@ -66,6 +66,8 @@ class YamlDriver extends FileDriver
|
||||
isset($element['repositoryClass']) ? $element['repositoryClass'] : null
|
||||
);
|
||||
$metadata->isMappedSuperclass = true;
|
||||
} else if ($element['type'] == 'embeddable') {
|
||||
$metadata->isEmbeddedClass = true;
|
||||
} else {
|
||||
throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className);
|
||||
}
|
||||
@ -311,6 +313,16 @@ class YamlDriver extends FileDriver
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($element['embedded'])) {
|
||||
foreach ($element['embedded'] as $name => $embeddedMapping) {
|
||||
$mapping = array(
|
||||
'fieldName' => $name,
|
||||
'class' => $embeddedMapping['class'],
|
||||
'columnPrefix' => isset($embeddedMapping['columnPrefix']) ? $embeddedMapping['columnPrefix'] : null,
|
||||
);
|
||||
$metadata->mapEmbedded($mapping);
|
||||
}
|
||||
}
|
||||
|
||||
// Evaluate oneToOne relationships
|
||||
if (isset($element['oneToOne'])) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user