#881 DDC-2825 - refactoring mapping driver to use ClassMetadata#setPrimaryTable()
instead of duplicating explode()
logic
This commit is contained in:
parent
eefa3b2e53
commit
f0102a69f9
@ -93,19 +93,10 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
||||
|
||||
// Evaluate Table annotation
|
||||
if (isset($classAnnotations['Doctrine\ORM\Mapping\Table'])) {
|
||||
$tableAnnot = $classAnnotations['Doctrine\ORM\Mapping\Table'];
|
||||
|
||||
$tableName = $tableAnnot->name;
|
||||
$schemaName = $tableAnnot->schema;
|
||||
|
||||
// Split schema and table name from a table name like "myschema.mytable"
|
||||
if (strpos($tableName, '.') !== false) {
|
||||
list($schemaName, $tableName) = explode('.', $tableName);
|
||||
}
|
||||
|
||||
$tableAnnot = $classAnnotations['Doctrine\ORM\Mapping\Table'];
|
||||
$primaryTable = array(
|
||||
'name' => $tableName,
|
||||
'schema' => $schemaName
|
||||
'name' => $tableAnnot->name,
|
||||
'schema' => $tableAnnot->schema
|
||||
);
|
||||
|
||||
if ($tableAnnot->indexes !== null) {
|
||||
|
@ -76,29 +76,17 @@ class XmlDriver extends FileDriver
|
||||
}
|
||||
|
||||
// Evaluate <entity...> attributes
|
||||
$table = array();
|
||||
|
||||
$tableName = null;
|
||||
$schemaName = null;
|
||||
$primaryTable = array();
|
||||
|
||||
if (isset($xmlRoot['table'])) {
|
||||
$tableName = (string)$xmlRoot['table'];
|
||||
|
||||
// Split schema and table name from a table name like "myschema.mytable"
|
||||
if (strpos($tableName, '.') !== false) {
|
||||
list($metadata->table['schema'], $tableName) = explode('.', $tableName);
|
||||
}
|
||||
$primaryTable['name'] = (string) $xmlRoot['table'];
|
||||
}
|
||||
|
||||
if (isset($xmlRoot['schema'])) {
|
||||
$metadata->table['schema'] = (string) $xmlRoot['schema'];
|
||||
$primaryTable['schema'] = (string) $xmlRoot['schema'];
|
||||
}
|
||||
|
||||
if (null !== $tableName) {
|
||||
$table['name'] = $tableName;
|
||||
}
|
||||
|
||||
$metadata->setPrimaryTable($table);
|
||||
$metadata->setPrimaryTable($primaryTable);
|
||||
|
||||
// Evaluate second level cache
|
||||
if (isset($xmlRoot->cache)) {
|
||||
|
@ -73,26 +73,14 @@ class YamlDriver extends FileDriver
|
||||
}
|
||||
|
||||
// Evaluate root level properties
|
||||
$table = array();
|
||||
|
||||
$tableName = null;
|
||||
$schemaName = null;
|
||||
$primaryTable = array();
|
||||
|
||||
if (isset($element['table'])) {
|
||||
$tableName = $element['table'];
|
||||
|
||||
// Split schema and table name from a table name like "myschema.mytable"
|
||||
if (strpos($tableName, '.') !== false) {
|
||||
list($table['schema'], $tableName) = explode('.', $tableName, 2);
|
||||
}
|
||||
$primaryTable['name'] = $element['table'];
|
||||
}
|
||||
|
||||
if (isset($element['schema'])) {
|
||||
$table['schema'] = $element['schema'];
|
||||
}
|
||||
|
||||
if (null !== $tableName) {
|
||||
$table['name'] = $tableName;
|
||||
$primaryTable['schema'] = $element['schema'];
|
||||
}
|
||||
|
||||
// Evaluate second level cache
|
||||
@ -100,7 +88,7 @@ class YamlDriver extends FileDriver
|
||||
$metadata->enableCache($this->cacheToArray($element['cache']));
|
||||
}
|
||||
|
||||
$metadata->setPrimaryTable($table);
|
||||
$metadata->setPrimaryTable($primaryTable);
|
||||
|
||||
// Evaluate named queries
|
||||
if (isset($element['namedQueries'])) {
|
||||
|
Loading…
Reference in New Issue
Block a user