Fixes for new yml schema.
This commit is contained in:
parent
2279cf8bef
commit
1dc60451c5
@ -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'];
|
||||
$relations = $properties['relations'];
|
||||
|
||||
foreach ($columns as $column) {
|
||||
if ($this->isRelation($column)) {
|
||||
$this->addRelationColumn($className, $column);
|
||||
}
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user