diff --git a/lib/Doctrine/Import/Schema.php b/lib/Doctrine/Import/Schema.php index 2e6c3e430..eff1ebe8e 100644 --- a/lib/Doctrine/Import/Schema.php +++ b/lib/Doctrine/Import/Schema.php @@ -39,7 +39,7 @@ */ abstract class Doctrine_Import_Schema { - public $relationColumns = array(); + public $relations = array(); /** * Parse the schema and return it in an array @@ -86,7 +86,7 @@ abstract class Doctrine_Import_Schema $array = array_merge($array, $this->parseSchema($s)); } - $this->buildRelations($array); + $this->buildRelationships($array); foreach ($array as $name => $properties) { $options = array(); @@ -101,34 +101,20 @@ abstract class Doctrine_Import_Schema } } - public function buildRelations($array) + public function buildRelationships($array) { foreach($array AS $name => $properties) { $className = $properties['className']; - $columns = $properties['columns']; - - foreach ($columns as $column) { - if ($this->isRelation($column)) { - $this->addRelationColumn($className, $column); - } + $relations = $properties['relations']; + + foreach ($relations AS $alias => $relation) { + $class = isset($relation['class']) ? $relation['class']:$alias; + + $relation['alias'] = $alias; + $relation['class'] = $class; + + $this->relations[$className][$class] = $relation; } } - - $this->processRelationships(); - } - - public function isRelation($column) - { - return isset($column['foreignClass']) && isset($column['foreignReference']); - } - - public function addRelationColumn($className, $column) - { - $this->relationColumns[$className][] = $column; - } - - public function processRelationships() - { - } } \ No newline at end of file diff --git a/lib/Doctrine/Import/Schema/Yml.php b/lib/Doctrine/Import/Schema/Yml.php index b53721c88..37901b88b 100644 --- a/lib/Doctrine/Import/Schema/Yml.php +++ b/lib/Doctrine/Import/Schema/Yml.php @@ -51,6 +51,7 @@ class Doctrine_Import_Schema_Yml extends Doctrine_Import_Schema public function parseSchema($schema) { $array = $this->parse($schema); + foreach ($array as $tableName => $table) { $columns = array(); @@ -70,13 +71,6 @@ class Doctrine_Import_Schema_Yml extends Doctrine_Import_Schema $colDesc['default'] = isset($field['default']) ? (string) $field['default']:null; $colDesc['notnull'] = isset($field['notnull']) ? (bool) (isset($field['notnull']) && $field['notnull']):null; $colDesc['autoinc'] = isset($field['autoinc']) ? (bool) (isset($field['autoinc']) && $field['autoinc']):null; - $colDesc['foreignClass'] = isset($field['foreignClass']) ? (string) $field['foreignClass']:null; - $colDesc['foreignReference'] = isset($field['foreignReference']) ? (string) $field['foreignReference']:null; - $colDesc['localName'] = isset($field['localName']) ? (string) $field['localName']:null; - $colDesc['foreignName'] = isset($field['foreignName']) ? (string) $field['foreignName']:null; - $colDesc['counterpart'] = isset($field['counterpart']) ? (string) $field['counterpart']:null; - $colDesc['onDelete'] = isset($field['onDelete']) ? (string) $field['onDelete']:null; - $colDesc['onUpdate'] = isset($field['onUpdate']) ? (string) $field['onUpdate']:null; $columns[(string) $colDesc['name']] = $colDesc; } @@ -85,6 +79,7 @@ class Doctrine_Import_Schema_Yml extends Doctrine_Import_Schema $tables[$tableName]['className'] = $className; $tables[$tableName]['columns'] = $columns; + $tables[$tableName]['relations'] = isset($table['relations']) ? $table['relations']:array(); } return $tables;