1
0
mirror of synced 2025-01-05 16:53:21 +03:00
This commit is contained in:
zYne 2007-07-23 20:28:46 +00:00
parent 3a6ce5a6c6
commit c26ed8441b
2 changed files with 11 additions and 6 deletions

View File

@ -192,7 +192,8 @@ class Doctrine_Import extends Doctrine_Connection_Module
foreach ($this->listTables() as $table) { foreach ($this->listTables() as $table) {
$builder->buildRecord(array('tableName' => $table, $builder->buildRecord(array('tableName' => $table,
'className' => Doctrine::classify($table)), 'className' => Doctrine::classify($table)),
$this->listTableColumns($table)); $this->listTableColumns($table),
array());
$classes[] = Doctrine::classify($table); $classes[] = Doctrine::classify($table);
} }

View File

@ -224,9 +224,13 @@ END;
return $content; return $content;
} }
public function buildRecord($table, $columns, $relations) public function buildRecord($options, $columns, $relations)
{ {
if (empty($fileName)) { if ( ! isset($options['className'])) {
throw new Doctrine_Import_Builder_Exception('Missing class name.');
}
if ( ! isset($options['fileName'])) {
if (empty($this->path)) { if (empty($this->path)) {
$errMsg = 'No build target directory set.'; $errMsg = 'No build target directory set.';
throw new Doctrine_Import_Builder_Exception($errMsg); throw new Doctrine_Import_Builder_Exception($errMsg);
@ -238,15 +242,15 @@ END;
throw new Doctrine_Import_Builder_Exception($errMsg); throw new Doctrine_Import_Builder_Exception($errMsg);
} }
$fileName = $this->path . DIRECTORY_SEPARATOR . $className . $this->suffix; $options['fileName'] = $this->path . DIRECTORY_SEPARATOR . $options['className'] . $this->suffix;
} }
$content = $this->buildDefinition($options, $columns, $relations); $content = $this->buildDefinition($options, $columns, $relations);
$bytes = file_put_contents($fileName, '<?php' . PHP_EOL . $content); $bytes = file_put_contents($options['fileName'], '<?php' . PHP_EOL . $content);
if ($bytes === false) { if ($bytes === false) {
throw new Doctrine_Import_Builder_Exception("Couldn't write file " . $fileName); throw new Doctrine_Import_Builder_Exception("Couldn't write file " . $options['fileName']);
} }
} }
} }