Commit 3e39fcf3 authored by phuson's avatar phuson

Implemented generation for loadTemplate() from Schema file.

parent e63393cd
......@@ -210,6 +210,26 @@ END;
$i++;
}
if (isset($options['templates']) && !empty($options['templates'])) {
$ret[$i] = PHP_EOL .str_repeat(' ', 8) . '// Load Class Template(s)';
$i++;
if (!is_array($options['templates'])) {
// explode to extract each template separated by commas
$templatesArray = explode(',', $options['templates']);
} else {
// set the existing array to templatesArray to be traversed through
$templatesArray = $options['templates'];
}
foreach ($templatesArray as $templateName) {
$ret[$i] = str_repeat(' ', 8) . '$this->loadTemplate(\''. trim($templateName) .'\');';
$i++;
}
$ret[$i] = '';
$i++;
}
foreach ($columns as $name => $column) {
$ret[$i] = ' $this->hasColumn(\'' . $name . '\', \'' . $column['type'] . '\'';
......
......@@ -139,6 +139,7 @@ class Doctrine_Import_Schema
$options['className'] = $properties['className'];
$options['fileName'] = $directory.DIRECTORY_SEPARATOR.$properties['className'].'.class.php';
$options['tableName'] = isset($properties['tableName']) ? $properties['tableName']:null;
$options['templates'] = isset($properties['templates']) ? $properties['templates']:null;
if (isset($properties['inheritance'])) {
$options['inheritance'] = $properties['inheritance'];
......@@ -239,6 +240,7 @@ class Doctrine_Import_Schema
$build[$className]['tableName'] = $tableName;
$build[$className]['columns'] = $columns;
$build[$className]['templates'] = isset($table['templates']) ? $table['templates']:array();
$build[$className]['relations'] = isset($table['relations']) ? $table['relations']:array();
$build[$className]['indexes'] = isset($table['indexes']) ? $table['indexes']:array();
$build[$className]['attributes'] = isset($table['attributes']) ? $table['attributes']:array();
......
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