This commit is contained in:
parent
5738fed7a6
commit
69985832a7
@ -30,7 +30,7 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_AuditLog extends Doctrine_Plugin
|
||||
class Doctrine_AuditLog extends Doctrine_Record_Generator
|
||||
{
|
||||
protected $_options = array(
|
||||
'className' => '%CLASS%Version',
|
||||
|
@ -1153,7 +1153,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
|
||||
}
|
||||
|
||||
if ($table->getAttribute(Doctrine::ATTR_EXPORT) & Doctrine::EXPORT_PLUGINS) {
|
||||
$sql = array_merge($sql, $this->exportPluginsSql($table));
|
||||
$sql = array_merge($sql, $this->exportGeneratorsSql($table));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1165,45 +1165,45 @@ class Doctrine_Export extends Doctrine_Connection_Module
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches all plugins recursively for given table
|
||||
* fetches all generators recursively for given table
|
||||
*
|
||||
* @param Doctrine_Table $table table object to retrieve the plugins from
|
||||
* @return array an array of Doctrine_Plugin objects
|
||||
* @param Doctrine_Table $table table object to retrieve the generators from
|
||||
* @return array an array of Doctrine_Record_Generator objects
|
||||
*/
|
||||
public function getAllPlugins(Doctrine_Table $table)
|
||||
public function getAllGenerators(Doctrine_Table $table)
|
||||
{
|
||||
$plugins = array();
|
||||
$generators = array();
|
||||
|
||||
foreach ($table->getPlugins() as $name => $plugin) {
|
||||
if ($plugin === null) {
|
||||
foreach ($table->getGenerators() as $name => $generator) {
|
||||
if ($generator === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$plugins[] = $plugin;
|
||||
$generators[] = $generator;
|
||||
|
||||
$pluginTable = $plugin->getTable();
|
||||
$generatorTable = $generator->getTable();
|
||||
|
||||
if ($pluginTable instanceof Doctrine_Table) {
|
||||
$plugins = array_merge($plugins, $this->getAllPlugins($pluginTable));
|
||||
if ($generatorTable instanceof Doctrine_Table) {
|
||||
$generators = array_merge($generators, $this->getAllGenerators($generatorTable));
|
||||
}
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
return $generators;
|
||||
}
|
||||
|
||||
/**
|
||||
* exportPluginsSql
|
||||
* exportGeneratorsSql
|
||||
* 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
|
||||
* @param Doctrine_Table $table the table in which the generators belong to
|
||||
* @return array an array of sql strings
|
||||
*/
|
||||
public function exportPluginsSql(Doctrine_Table $table)
|
||||
public function exportGeneratorsSql(Doctrine_Table $table)
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
foreach ($this->getAllPlugins($table) as $name => $plugin) {
|
||||
$table = $plugin->getTable();
|
||||
foreach ($this->getAllGenerators($table) as $name => $generator) {
|
||||
$table = $generator->getTable();
|
||||
|
||||
// Make sure plugin has a valid table
|
||||
if ($table instanceof Doctrine_Table) {
|
||||
|
@ -30,7 +30,7 @@
|
||||
* @version $Revision$
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
*/
|
||||
class Doctrine_I18n extends Doctrine_Plugin
|
||||
class Doctrine_I18n extends Doctrine_Record_Generator
|
||||
{
|
||||
protected $_options = array(
|
||||
'className' => '%CLASS%Translation',
|
||||
|
@ -294,11 +294,11 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function loadPlugin(Doctrine_Plugin $plugin)
|
||||
public function loadGenerator(Doctrine_Record_Generator $generator)
|
||||
{
|
||||
$plugin->initialize($this->_table);
|
||||
$generator->initialize($this->_table);
|
||||
|
||||
$this->_table->addPlugin($plugin, get_class($plugin));
|
||||
$this->_table->addGenerator($generator, get_class($generator));
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Doctrine_Plugin
|
||||
* Doctrine_Record_Generator
|
||||
*
|
||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
||||
* @package Doctrine
|
||||
@ -30,7 +30,7 @@
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
abstract class Doctrine_Plugin extends Doctrine_Record_Abstract
|
||||
abstract class Doctrine_Record_Generator extends Doctrine_Record_Abstract
|
||||
{
|
||||
/**
|
||||
* @var array $_options an array of plugin specific options
|
||||
@ -96,7 +96,7 @@ abstract class Doctrine_Plugin extends Doctrine_Record_Abstract
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addChild(Doctrine_Template $template)
|
||||
public function addChild(Doctrine_Record_Generator $template)
|
||||
{
|
||||
$this->_options['children'][] = $template;
|
||||
}
|
||||
@ -121,7 +121,7 @@ abstract class Doctrine_Plugin extends Doctrine_Record_Abstract
|
||||
|
||||
$this->initOptions();
|
||||
|
||||
$table->addPlugin($this, get_class($this));
|
||||
$table->addGenerator($this, get_class($this));
|
||||
|
||||
$this->_options['table'] = $table;
|
||||
|
||||
@ -171,7 +171,7 @@ abstract class Doctrine_Plugin extends Doctrine_Record_Abstract
|
||||
}
|
||||
|
||||
foreach ($this->_options['children'] as $child) {
|
||||
$this->_table->addTemplate(get_class($child), $child);
|
||||
$this->_table->addGenerator($child, get_class($child));
|
||||
|
||||
$child->setTable($this->_table);
|
||||
|
||||
@ -274,7 +274,7 @@ abstract class Doctrine_Plugin extends Doctrine_Record_Abstract
|
||||
|
||||
$builder->buildRecord($options, $columns, $relations);
|
||||
} else {
|
||||
throw new Doctrine_Plugin_Exception('If you wish to generate files then you must specify the path to generate the files in.');
|
||||
throw new Doctrine_Record_Exception('If you wish to generate files then you must specify the path to generate the files in.');
|
||||
}
|
||||
} else {
|
||||
$def = $builder->buildDefinition($options, $columns, $relations);
|
@ -30,7 +30,7 @@
|
||||
* @link www.phpdoctrine.com
|
||||
* @since 1.0
|
||||
*/
|
||||
class Doctrine_Search extends Doctrine_Plugin
|
||||
class Doctrine_Search extends Doctrine_Record_Generator
|
||||
{
|
||||
const INDEX_FILES = 0;
|
||||
|
||||
|
@ -186,14 +186,15 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
|
||||
protected $_templates = array();
|
||||
|
||||
/**
|
||||
* @see Doctrine_Record_Filter
|
||||
* @var array $_filters an array containing all record filters attached to this table
|
||||
*/
|
||||
protected $_filters = array();
|
||||
/**
|
||||
* @see Doctrine_Plugin
|
||||
* @var array $_plugins an array containing all plugins attached to this table
|
||||
* @see Doctrine_Record_Generator
|
||||
* @var array $_generators an array containing all generators attached to this table
|
||||
*/
|
||||
protected $_plugins = array();
|
||||
protected $_generators = array();
|
||||
|
||||
/**
|
||||
* @var array $_invokedMethods method invoker cache
|
||||
@ -609,28 +610,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
|
||||
'options' => array_merge($this->getOptions(), $options));
|
||||
}
|
||||
|
||||
/**
|
||||
* exportConstraints
|
||||
* exports the constraints of this table into database based on option definitions
|
||||
*
|
||||
* @throws Doctrine_Connection_Exception if something went wrong on db level
|
||||
* @return void
|
||||
*/
|
||||
public function exportConstraints()
|
||||
{
|
||||
try {
|
||||
$this->_conn->beginTransaction();
|
||||
|
||||
foreach ($this->_options['index'] as $index => $definition) {
|
||||
$this->_conn->export->createIndex($this->_options['tableName'], $index, $definition);
|
||||
}
|
||||
$this->_conn->commit();
|
||||
} catch (Doctrine_Connection_Exception $e) {
|
||||
$this->_conn->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getRelationParser
|
||||
* return the relation parser associated with this table
|
||||
@ -1763,30 +1742,30 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function getPlugins()
|
||||
public function getGenerators()
|
||||
{
|
||||
return $this->_plugins;
|
||||
return $this->_generators;
|
||||
}
|
||||
public function getPlugin($plugin)
|
||||
public function getGenerator($generator)
|
||||
{
|
||||
if ( ! isset($this->_plugins[$plugin])) {
|
||||
throw new Doctrine_Table_Exception('Plugin ' . $plugin . ' not loaded');
|
||||
if ( ! isset($this->_generators[$generator])) {
|
||||
throw new Doctrine_Table_Exception('Generator ' . $generator . ' not loaded');
|
||||
}
|
||||
|
||||
return $this->_plugins[$plugin];
|
||||
return $this->_generators[$plugin];
|
||||
}
|
||||
|
||||
public function hasPlugin($plugin)
|
||||
public function hasGenerator($generator)
|
||||
{
|
||||
return isset($this->_plugins[$plugin]);
|
||||
return isset($this->_generators[$generator]);
|
||||
}
|
||||
|
||||
public function addPlugin(Doctrine_Plugin $plugin, $name = null)
|
||||
public function addGenerator(Doctrine_Record_Generator $generator, $name = null)
|
||||
{
|
||||
if ($name === null) {
|
||||
$this->_plugins[] = $plugin;
|
||||
$this->_generators[] = $generator;
|
||||
} else {
|
||||
$this->_plugins[$name] = $plugin;
|
||||
$this->_generators[$name] = $generator;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user