1
0
mirror of synced 2025-02-20 22:23:14 +03:00

Fixes to indexes and to not call parent::setUp() in the base classes.

This commit is contained in:
Jonathan.Wage 2007-10-15 14:09:59 +00:00
parent 34af8e3aa1
commit 38331335ab
2 changed files with 23 additions and 19 deletions

View File

@ -268,6 +268,7 @@ END;
return "\n\tpublic function setTableDefinition()"."\n\t{\n".implode("\n", $ret)."\n\t}";
}
}
public function buildSetUp(array $options, array $columns, array $relations)
{
$ret = array();
@ -413,6 +414,7 @@ END;
$options['className'] = 'Base' . $options['className'];
$options['abstract'] = true;
$options['fileName'] = $generatedPath . DIRECTORY_SEPARATOR . $options['className'] . $this->suffix;
$options['override_parent'] = true;
$this->writeDefinition($options, $columns, $relations, $indexes);
} else {
@ -422,24 +424,25 @@ END;
public function writeDefinition(array $options, array $columns, array $relations = array(), array $indexes = array())
{
$content = $this->buildDefinition($options, $columns, $relations, $indexes);
$code = "<?php\n";
if (isset($options['requires'])) {
if (!is_array($options['requires'])) {
$options['requires'] = array($options['requires']);
}
foreach ($options['requires'] as $require) {
$code .= "require_once('".$require."');";
}
}
$code .= PHP_EOL . $content;
$bytes = file_put_contents($options['fileName'], $code);
$content = $this->buildDefinition($options, $columns, $relations, $indexes);
$code = "<?php\n";
if ($bytes === false) {
throw new Doctrine_Import_Builder_Exception("Couldn't write file " . $options['fileName']);
}
if (isset($options['requires'])) {
if (!is_array($options['requires'])) {
$options['requires'] = array($options['requires']);
}
foreach ($options['requires'] as $require) {
$code .= "require_once('".$require."');";
}
}
$code .= PHP_EOL . $content;
$bytes = file_put_contents($options['fileName'], $code);
if ($bytes === false) {
throw new Doctrine_Import_Builder_Exception("Couldn't write file " . $options['fileName']);
}
}
}

View File

@ -119,8 +119,9 @@ class Doctrine_Import_Schema
$options = $this->getOptions($properties, $directory);
$columns = $this->getColumns($properties);
$relations = $this->getRelations($properties);
$indexes = $this->getIndexes($properties);
$builder->buildRecord($options, $columns, $relations);
$builder->buildRecord($options, $columns, $relations, $indexes);
}
}