1
0
mirror of synced 2025-01-18 06:21:40 +03:00
This commit is contained in:
zYne 2007-09-06 20:23:52 +00:00
parent eed203594e
commit ec6120b955
3 changed files with 43 additions and 2 deletions

View File

@ -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

View File

@ -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;
}
}

View File

@ -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()
{