This commit is contained in:
parent
eed203594e
commit
ec6120b955
@ -1043,7 +1043,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
|
|||||||
// check if class is an instance of Doctrine_Record and not abstract
|
// 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)
|
// 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
|
// 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() ||
|
while ($class->isAbstract() ||
|
||||||
! $class->isSubclassOf($parent) ||
|
! $class->isSubclassOf($parent) ||
|
||||||
! $class->hasMethod('setTableDefinition') ||
|
! $class->hasMethod('setTableDefinition') ||
|
||||||
@ -1057,11 +1057,12 @@ class Doctrine_Export extends Doctrine_Connection_Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($class === false) {
|
if ($class === false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$record = new $name();
|
$record = new $name();
|
||||||
$table = $record->getTable();
|
$table = $record->getTable();
|
||||||
|
|
||||||
$data = $table->getExportableFormat();
|
$data = $table->getExportableFormat();
|
||||||
|
|
||||||
$query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options']);
|
$query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options']);
|
||||||
@ -1071,12 +1072,38 @@ class Doctrine_Export extends Doctrine_Connection_Module
|
|||||||
} else {
|
} else {
|
||||||
$sql[] = $query;
|
$sql[] = $query;
|
||||||
}
|
}
|
||||||
|
if ($table->getAttribute(Doctrine::ATTR_EXPORT) & Doctrine::EXPORT_PLUGINS) {
|
||||||
|
$sql = array_merge($sql, $this->exportPluginsSql($table));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$sql = array_unique($sql);
|
$sql = array_unique($sql);
|
||||||
rsort($sql);
|
rsort($sql);
|
||||||
|
|
||||||
return $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
|
* exportSql
|
||||||
* returns the sql for exporting Doctrine_Record classes to a schema
|
* returns the sql for exporting Doctrine_Record classes to a schema
|
||||||
|
@ -36,6 +36,7 @@ class Doctrine_I18n extends Doctrine_Plugin
|
|||||||
'fields' => array(),
|
'fields' => array(),
|
||||||
'generateFiles' => false,
|
'generateFiles' => false,
|
||||||
'table' => false,
|
'table' => false,
|
||||||
|
'pluginTable' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $_auditTable;
|
protected $_auditTable;
|
||||||
@ -109,6 +110,8 @@ class Doctrine_I18n extends Doctrine_Plugin
|
|||||||
if ( ! $this->_options['generateFiles']) {
|
if ( ! $this->_options['generateFiles']) {
|
||||||
eval($def);
|
eval($def);
|
||||||
}
|
}
|
||||||
|
$this->_options['pluginTable'] = $table->getConnection()->getTable($this->_options['className']);
|
||||||
|
|
||||||
return true;
|
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
|
* @param Doctrine_Record $_invoker the record that invoked the last delegated call
|
||||||
*/
|
*/
|
||||||
protected $_invoker;
|
protected $_invoker;
|
||||||
|
|
||||||
|
|
||||||
|
protected $_plugin;
|
||||||
/**
|
/**
|
||||||
* setTable
|
* setTable
|
||||||
*
|
*
|
||||||
@ -77,6 +80,14 @@ class Doctrine_Template extends Doctrine_Record_Abstract
|
|||||||
{
|
{
|
||||||
return $this->_invoker;
|
return $this->_invoker;
|
||||||
}
|
}
|
||||||
|
public function get()
|
||||||
|
{
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
public function getPlugin()
|
||||||
|
{
|
||||||
|
return $this->_plugin;
|
||||||
|
}
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user