From cc998bf1654736959fe1b790ab2d1ddb714e953e Mon Sep 17 00:00:00 2001 From: zYne Date: Thu, 7 Jun 2007 18:21:07 +0000 Subject: [PATCH] --- lib/Doctrine/AuditLog.php | 26 ++++++++++---------------- lib/Doctrine/Configurable.php | 4 +++- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/Doctrine/AuditLog.php b/lib/Doctrine/AuditLog.php index 72d086c46..7d4720c46 100644 --- a/lib/Doctrine/AuditLog.php +++ b/lib/Doctrine/AuditLog.php @@ -36,7 +36,7 @@ class Doctrine_AuditLog 'deleteTrigger' => '%TABLE%_ddt', 'updateTrigger' => '%TABLE%_dut', 'versionTable' => '%TABLE%_dvt', - 'identifier' => '__version', + 'versionColumn' => 'version', ); protected $_table; @@ -54,7 +54,7 @@ class Doctrine_AuditLog public function __get($option) { if (isset($this->options[$option])) { - return $this->options[$option]; + return $this->_options[$option]; } return null; } @@ -65,7 +65,7 @@ class Doctrine_AuditLog */ public function __isset($option) { - return isset($this->options[$option]); + return isset($this->_options[$option]); } /** * getOptions @@ -75,7 +75,7 @@ class Doctrine_AuditLog */ public function getOptions() { - return $this->options; + return $this->_options; } /** * setOption @@ -92,7 +92,7 @@ class Doctrine_AuditLog if ( ! isset($this->_options[$name])) { throw new Doctrine_Exception('Unknown option ' . $name); } - $this->options[$name] = $value; + $this->_options[$name] = $value; } /** * getOption @@ -103,8 +103,8 @@ class Doctrine_AuditLog */ public function getOption($name) { - if (isset($this->options[$name])) { - return $this->options[$name]; + if (isset($this->_options[$name])) { + return $this->_options[$name]; } return null; } @@ -142,13 +142,6 @@ class Doctrine_AuditLog } - $data['columns'] = array_merge(array($this->_options['identifier'] => - array('type' => 'integer', - 'primary' => true, - 'length' => 8, - 'autoinc' => true)), $data['columns']); - - $className = str_replace('%CLASS%', $this->_table->getComponentName(), $this->_options['className']); $definition = 'class ' . $className . ' extends Doctrine_Record { ' @@ -161,10 +154,11 @@ class Doctrine_AuditLog 'foreign' => $this->_table->getIdentifier(), 'type' => Doctrine_Relation::MANY)); - print $definition; + + $this->_table->addListener(new Doctrine_AuditLog_Listener($this)); eval( $definition ); - $data['options']['primary'] = array($this->_options['identifier']); + $conn->export->createTable($data['tableName'], $data['columns'], $data['options']); } diff --git a/lib/Doctrine/Configurable.php b/lib/Doctrine/Configurable.php index ca62d355c..2d73e5446 100644 --- a/lib/Doctrine/Configurable.php +++ b/lib/Doctrine/Configurable.php @@ -175,7 +175,9 @@ abstract class Doctrine_Configurable */ public function addListener($listener, $name = null) { - if ( ! ($this->attributes[Doctrine::ATTR_LISTENER] instanceof Doctrine_EventListener_Chain)) { + if ( ! isset($this->attributes[Doctrine::ATTR_LISTENER]) || + ! ($this->attributes[Doctrine::ATTR_LISTENER] instanceof Doctrine_EventListener_Chain)) { + $this->attributes[Doctrine::ATTR_LISTENER] = new Doctrine_EventListener_Chain(); } $this->attributes[Doctrine::ATTR_LISTENER]->add($listener, $name);