-
This commit is contained in:
parent
50ab186792
commit
37cec1d690
@ -48,14 +48,14 @@ class Doctrine_Export_Schema
|
||||
*/
|
||||
public function buildSchema($directory = null, $models = array())
|
||||
{
|
||||
$array = array();
|
||||
|
||||
if ($directory) {
|
||||
$loadedModels = Doctrine::loadModels($directory);
|
||||
} else {
|
||||
$loadedModels = Doctrine::getLoadedModels();
|
||||
}
|
||||
|
||||
$array = array();
|
||||
|
||||
$parent = new ReflectionClass('Doctrine_Record');
|
||||
|
||||
$sql = array();
|
||||
@ -68,28 +68,6 @@ class Doctrine_Export_Schema
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = new ReflectionClass($name);
|
||||
|
||||
// check if class is an instance of Doctrine_Record and not abstract
|
||||
// class must have method setTableDefinition (to avoid non-Record subclasses like symfony's sfDoctrineRecord)
|
||||
// we have to recursively iterate through the class parents just to be sure that the classes using for example
|
||||
// column aggregation inheritance are properly exported to database
|
||||
while ($class->isAbstract() ||
|
||||
! $class->isSubclassOf($parent) ||
|
||||
! $class->hasMethod('setTableDefinition') ||
|
||||
( $class->hasMethod('setTableDefinition') &&
|
||||
$class->getMethod('setTableDefinition')->getDeclaringClass()->getName() !== $class->getName())) {
|
||||
|
||||
$class = $class->getParentClass();
|
||||
if ($class === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($class === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$record = new $name();
|
||||
$recordTable = $record->getTable();
|
||||
|
||||
|
@ -173,7 +173,11 @@ class Doctrine_Facade
|
||||
|
||||
$export = new Doctrine_Export_Schema();
|
||||
|
||||
return $export->exportSchema($yamlPath, 'yml', $directory);
|
||||
$result = $export->exportSchema($yamlPath, 'yml', $directory);
|
||||
|
||||
exec('rm -rf ' . $directory);
|
||||
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* generateModelsFromYaml
|
||||
|
Loading…
Reference in New Issue
Block a user