diff --git a/lib/Doctrine/Template/Listener/Timestampable.php b/lib/Doctrine/Template/Listener/Timestampable.php index eb50ffa29..3756e98d7 100644 --- a/lib/Doctrine/Template/Listener/Timestampable.php +++ b/lib/Doctrine/Template/Listener/Timestampable.php @@ -38,7 +38,7 @@ class Doctrine_Template_Listener_Timestampable extends Doctrine_Record_Listener * @var string */ protected $_options = array(); - + /** * __construct * @@ -49,7 +49,7 @@ class Doctrine_Template_Listener_Timestampable extends Doctrine_Record_Listener { $this->_options = $options; } - + /** * preInsert * @@ -68,7 +68,7 @@ class Doctrine_Template_Listener_Timestampable extends Doctrine_Record_Listener $event->getInvoker()->$updatedName = $this->getTimestamp('updated'); } } - + /** * preUpdate * @@ -82,7 +82,7 @@ class Doctrine_Template_Listener_Timestampable extends Doctrine_Record_Listener $event->getInvoker()->$updatedName = $this->getTimestamp('updated'); } } - + /** * getTimestamp * @@ -94,13 +94,17 @@ class Doctrine_Template_Listener_Timestampable extends Doctrine_Record_Listener public function getTimestamp($type) { $options = $this->_options[$type]; - - if ($options['type'] == 'date') { - return date($options['format'], time()); - } else if ($options['type'] == 'timestamp') { - return date($options['format'], time()); + + if ($options['expression'] !== false && is_string($options['expression'])) { + return new Doctrine_Expression($options['expression']); } else { - return time(); + if ($options['type'] == 'date') { + return date($options['format'], time()); + } else if ($options['type'] == 'timestamp') { + return date($options['format'], time()); + } else { + return time(); + } } } } \ No newline at end of file diff --git a/lib/Doctrine/Template/Timestampable.php b/lib/Doctrine/Template/Timestampable.php index 0d6fc3cf4..5718cbb20 100644 --- a/lib/Doctrine/Template/Timestampable.php +++ b/lib/Doctrine/Template/Timestampable.php @@ -39,17 +39,19 @@ class Doctrine_Template_Timestampable extends Doctrine_Template * * @var string */ - protected $_options = array('created' => array('name' => 'created_at', - 'type' => 'timestamp', - 'format' => 'Y-m-d H:i:s', - 'disabled' => false, - 'options' => array()), - 'updated' => array('name' => 'updated_at', - 'type' => 'timestamp', - 'format' => 'Y-m-d H:i:s', - 'disabled' => false, - 'options' => array())); - + protected $_options = array('created' => array('name' => 'created_at', + 'type' => 'timestamp', + 'format' => 'Y-m-d H:i:s', + 'disabled' => false, + 'expression' => false, + 'options' => array()), + 'updated' => array('name' => 'updated_at', + 'type' => 'timestamp', + 'format' => 'Y-m-d H:i:s', + 'disabled' => false, + 'expression' => false, + 'options' => array())); + /** * __construct * @@ -60,7 +62,7 @@ class Doctrine_Template_Timestampable extends Doctrine_Template { $this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options); } - + /** * setTableDefinition *