1
0
mirror of synced 2024-12-05 03:06:05 +03:00

#881 DDC-2825 - refactoring mapping driver to use ClassMetadata#setPrimaryTable() instead of duplicating explode() logic

This commit is contained in:
Marco Pivetta 2015-01-14 18:12:12 +01:00
parent eefa3b2e53
commit f0102a69f9
3 changed files with 11 additions and 44 deletions

View File

@ -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) {

View File

@ -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)) {

View File

@ -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'])) {