Commit 69985832 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 5738fed7
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_AuditLog extends Doctrine_Plugin class Doctrine_AuditLog extends Doctrine_Record_Generator
{ {
protected $_options = array( protected $_options = array(
'className' => '%CLASS%Version', 'className' => '%CLASS%Version',
...@@ -104,4 +104,4 @@ class Doctrine_AuditLog extends Doctrine_Plugin ...@@ -104,4 +104,4 @@ class Doctrine_AuditLog extends Doctrine_Plugin
// the version column should be part of the primary key definition // the version column should be part of the primary key definition
$this->hasColumn($this->_options['versionColumn'], 'integer', 8, array('primary' => true)); $this->hasColumn($this->_options['versionColumn'], 'integer', 8, array('primary' => true));
} }
} }
\ No newline at end of file
...@@ -1153,7 +1153,7 @@ class Doctrine_Export extends Doctrine_Connection_Module ...@@ -1153,7 +1153,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
} }
if ($table->getAttribute(Doctrine::ATTR_EXPORT) & Doctrine::EXPORT_PLUGINS) { 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 ...@@ -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 * @param Doctrine_Table $table table object to retrieve the generators from
* @return array an array of Doctrine_Plugin objects * @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) { foreach ($table->getGenerators() as $name => $generator) {
if ($plugin === null) { if ($generator === null) {
continue; continue;
} }
$plugins[] = $plugin; $generators[] = $generator;
$pluginTable = $plugin->getTable(); $generatorTable = $generator->getTable();
if ($pluginTable instanceof Doctrine_Table) { if ($generatorTable instanceof Doctrine_Table) {
$plugins = array_merge($plugins, $this->getAllPlugins($pluginTable)); $generators = array_merge($generators, $this->getAllGenerators($generatorTable));
} }
} }
return $plugins; return $generators;
} }
/** /**
* exportPluginsSql * exportGeneratorsSql
* exports plugin tables for given table * exports plugin tables for given table
* *
* @param Doctrine_Table $table the table in which the plugins belong to * @param Doctrine_Table $table the table in which the generators belong to
* @return array an array of sql strings * @return array an array of sql strings
*/ */
public function exportPluginsSql(Doctrine_Table $table) public function exportGeneratorsSql(Doctrine_Table $table)
{ {
$sql = array(); $sql = array();
foreach ($this->getAllPlugins($table) as $name => $plugin) { foreach ($this->getAllGenerators($table) as $name => $generator) {
$table = $plugin->getTable(); $table = $generator->getTable();
// Make sure plugin has a valid table // Make sure plugin has a valid table
if ($table instanceof Doctrine_Table) { if ($table instanceof Doctrine_Table) {
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_I18n extends Doctrine_Plugin class Doctrine_I18n extends Doctrine_Record_Generator
{ {
protected $_options = array( protected $_options = array(
'className' => '%CLASS%Translation', 'className' => '%CLASS%Translation',
......
...@@ -294,11 +294,11 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access ...@@ -294,11 +294,11 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access
return $this; 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 @@ ...@@ -20,7 +20,7 @@
*/ */
/** /**
* Doctrine_Plugin * Doctrine_Record_Generator
* *
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @package Doctrine * @package Doctrine
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @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 * @var array $_options an array of plugin specific options
...@@ -96,7 +96,7 @@ abstract class Doctrine_Plugin extends Doctrine_Record_Abstract ...@@ -96,7 +96,7 @@ abstract class Doctrine_Plugin extends Doctrine_Record_Abstract
return $this; return $this;
} }
public function addChild(Doctrine_Template $template) public function addChild(Doctrine_Record_Generator $template)
{ {
$this->_options['children'][] = $template; $this->_options['children'][] = $template;
} }
...@@ -121,7 +121,7 @@ abstract class Doctrine_Plugin extends Doctrine_Record_Abstract ...@@ -121,7 +121,7 @@ abstract class Doctrine_Plugin extends Doctrine_Record_Abstract
$this->initOptions(); $this->initOptions();
$table->addPlugin($this, get_class($this)); $table->addGenerator($this, get_class($this));
$this->_options['table'] = $table; $this->_options['table'] = $table;
...@@ -171,7 +171,7 @@ abstract class Doctrine_Plugin extends Doctrine_Record_Abstract ...@@ -171,7 +171,7 @@ abstract class Doctrine_Plugin extends Doctrine_Record_Abstract
} }
foreach ($this->_options['children'] as $child) { foreach ($this->_options['children'] as $child) {
$this->_table->addTemplate(get_class($child), $child); $this->_table->addGenerator($child, get_class($child));
$child->setTable($this->_table); $child->setTable($this->_table);
...@@ -274,7 +274,7 @@ abstract class Doctrine_Plugin extends Doctrine_Record_Abstract ...@@ -274,7 +274,7 @@ abstract class Doctrine_Plugin extends Doctrine_Record_Abstract
$builder->buildRecord($options, $columns, $relations); $builder->buildRecord($options, $columns, $relations);
} else { } 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 { } else {
$def = $builder->buildDefinition($options, $columns, $relations); $def = $builder->buildDefinition($options, $columns, $relations);
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* @link www.phpdoctrine.com * @link www.phpdoctrine.com
* @since 1.0 * @since 1.0
*/ */
class Doctrine_Search extends Doctrine_Plugin class Doctrine_Search extends Doctrine_Record_Generator
{ {
const INDEX_FILES = 0; const INDEX_FILES = 0;
...@@ -264,4 +264,4 @@ class Doctrine_Search extends Doctrine_Plugin ...@@ -264,4 +264,4 @@ class Doctrine_Search extends Doctrine_Plugin
$this->hasColumns($columns); $this->hasColumns($columns);
} }
} }
\ No newline at end of file
...@@ -186,14 +186,15 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -186,14 +186,15 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
protected $_templates = array(); protected $_templates = array();
/** /**
* @see Doctrine_Record_Filter
* @var array $_filters an array containing all record filters attached to this table * @var array $_filters an array containing all record filters attached to this table
*/ */
protected $_filters = array(); protected $_filters = array();
/** /**
* @see Doctrine_Plugin * @see Doctrine_Record_Generator
* @var array $_plugins an array containing all plugins attached to this table * @var array $_generators an array containing all generators attached to this table
*/ */
protected $_plugins = array(); protected $_generators = array();
/** /**
* @var array $_invokedMethods method invoker cache * @var array $_invokedMethods method invoker cache
...@@ -609,28 +610,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -609,28 +610,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
'options' => array_merge($this->getOptions(), $options)); '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 * getRelationParser
* return the relation parser associated with this table * return the relation parser associated with this table
...@@ -1763,30 +1742,30 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -1763,30 +1742,30 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
return $this; 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])) { if ( ! isset($this->_generators[$generator])) {
throw new Doctrine_Table_Exception('Plugin ' . $plugin . ' not loaded'); 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) { if ($name === null) {
$this->_plugins[] = $plugin; $this->_generators[] = $generator;
} else { } else {
$this->_plugins[$name] = $plugin; $this->_generators[$name] = $generator;
} }
return $this; return $this;
} }
......
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