Commit ec6120b9 authored by zYne's avatar zYne

--no commit message

--no commit message
parent eed20359
......@@ -1043,7 +1043,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
// 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 exporterd to database
// column aggregation inheritance are properly exported to database
while ($class->isAbstract() ||
! $class->isSubclassOf($parent) ||
! $class->hasMethod('setTableDefinition') ||
......@@ -1057,11 +1057,12 @@ class Doctrine_Export extends Doctrine_Connection_Module
}
if ($class === false) {
continue;
continue;
}
$record = new $name();
$table = $record->getTable();
$data = $table->getExportableFormat();
$query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options']);
......@@ -1071,12 +1072,38 @@ class Doctrine_Export extends Doctrine_Connection_Module
} else {
$sql[] = $query;
}
if ($table->getAttribute(Doctrine::ATTR_EXPORT) & Doctrine::EXPORT_PLUGINS) {
$sql = array_merge($sql, $this->exportPluginsSql($table));
}
}
$sql = array_unique($sql);
rsort($sql);
return $sql;
}
/**
* exportPluginsSql
* exports plugin tables for given table
*
* @param Doctrine_Table $table the table in which the plugins belong to
* @return array an array of sql strings
*/
public function exportPluginsSql(Doctrine_Table $table)
{
$sql = array();
foreach ($table->getTemplates() as $name => $template) {
$table = $template->getPlugin()->getOption('pluginTable');
$data = $table->getExportableFormat();
$query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options']);
$sql = array_merge($sql, (array) $query);
}
return $sql;
}
/**
* exportSql
* returns the sql for exporting Doctrine_Record classes to a schema
......
......@@ -36,6 +36,7 @@ class Doctrine_I18n extends Doctrine_Plugin
'fields' => array(),
'generateFiles' => false,
'table' => false,
'pluginTable' => false,
);
protected $_auditTable;
......@@ -109,6 +110,8 @@ class Doctrine_I18n extends Doctrine_Plugin
if ( ! $this->_options['generateFiles']) {
eval($def);
}
$this->_options['pluginTable'] = $table->getConnection()->getTable($this->_options['className']);
return true;
}
}
......@@ -36,6 +36,9 @@ class Doctrine_Template extends Doctrine_Record_Abstract
* @param Doctrine_Record $_invoker the record that invoked the last delegated call
*/
protected $_invoker;
protected $_plugin;
/**
* setTable
*
......@@ -77,6 +80,14 @@ class Doctrine_Template extends Doctrine_Record_Abstract
{
return $this->_invoker;
}
public function get()
{
throw new Exception();
}
public function getPlugin()
{
return $this->_plugin;
}
public function setUp()
{
......
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