Commit d2d52a63 authored by Jonathan.Wage's avatar Jonathan.Wage

Tweaks to generated code.

parent 3f49cc73
......@@ -41,7 +41,7 @@ class Doctrine_Import_Builder
*/
private $path = '';
private $suffix = '.php';
private $suffix = '.class.php';
private $generateBaseClasses = false;
......@@ -134,15 +134,6 @@ END;
$i = 0;
$ret[$i] = "\t\tpublic function setTableDefinition()\n\t\t{";
$i++;
if (isset($options['inheritance']) && isset($options['inheritance']['extends'])) {
$ret[$i] = "\t\tparent::setTableDefinition();";
$i++;
}
if (isset($options['tableName']) && !empty($options['tableName'])) {
$ret[$i] = str_repeat(' ', 8) . '$this->setTableName(\''. $options['tableName'].'\');';
......@@ -196,7 +187,9 @@ END;
$i++;
}
return implode("\n", $ret)."\n\t\t}";
if (!empty($ret)) {
return "\n\t\tpublic function setTableDefinition()"."\n\t\t{\n\t\t\t\tparent::setTableDefinition();\n".implode("\n", $ret)."\n\t\t}";
}
}
public function buildSetUp(array $options, array $columns, array $relations)
{
......@@ -204,14 +197,6 @@ END;
$i = 0;
$ret[$i] = "\t\tpublic function setUp()\n\t\t{";
$i++;
if (isset($options['inheritance']) && isset($options['inheritance']['extends'])) {
$ret[$i] = "\t\tparent::setUp();";
$i++;
}
foreach ($relations as $name => $relation) {
$alias = (isset($relation['alias']) && $relation['alias'] !== $name) ? ' as ' . $relation['alias'] : '';
......@@ -267,7 +252,9 @@ END;
$ret[$i] = "\t\t".'$this->setInheritanceMap(array(\''.$options['inheritance']['keyField'].'\' => '.$options['inheritance']['keyValue'].'));';
}
return implode("\n", $ret)."\n\t\t}";
if (!empty($ret)) {
return "\n\t\tpublic function setUp()\n\t\t{\n\t\t\t\tparent::setUp();\n\t\t\t\t".implode("\n", $ret)."\n\t\t}";
}
}
public function buildDefinition(array $options, array $columns, array $relations = array())
......@@ -279,13 +266,8 @@ END;
$className = $options['className'];
$extends = isset($options['inheritance']['extends']) ? $options['inheritance']['extends']:'Doctrine_Record';
if (!isset($options['inheritance']['extends'])) {
$definition = $this->buildTableDefinition($options, $columns, $relations);
$setUp = $this->buildSetUp($options, $columns, $relations);
} else {
$definition = null;
$setUp = null;
}
$content = sprintf(self::$tpl, $className,
$extends,
......@@ -316,6 +298,7 @@ END;
if ($this->generateBaseClasses()) {
if (!file_exists($options['fileName'])) {
$optionsBak = $options;
unset($options['tableName']);
......@@ -323,6 +306,7 @@ END;
$this->writeDefinition($options, array(), array());
$options = $optionsBak;
}
$generatedPath = $this->path . DIRECTORY_SEPARATOR . $this->baseClassesDirectory;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment