Changeset 3682
- Timestamp:
- 01/30/08 01:04:54 (17 months ago)
- Location:
- branches
- Files:
-
- 4 modified
-
0.10/lib/Doctrine/Template/Listener/Timestampable.php (modified) (5 diffs)
-
0.10/lib/Doctrine/Template/Timestampable.php (modified) (2 diffs)
-
0.9/lib/Doctrine/Template/Listener/Timestampable.php (modified) (5 diffs)
-
0.9/lib/Doctrine/Template/Timestampable.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/lib/Doctrine/Template/Listener/Timestampable.php
r3676 r3682 39 39 */ 40 40 protected $_options = array(); 41 41 42 42 /** 43 43 * __construct … … 50 50 $this->_options = $options; 51 51 } 52 52 53 53 /** 54 54 * preInsert … … 69 69 } 70 70 } 71 71 72 72 /** 73 73 * preUpdate … … 83 83 } 84 84 } 85 85 86 86 /** 87 87 * getTimestamp … … 95 95 { 96 96 $options = $this->_options[$type]; 97 98 if ($options['type'] == 'date') { 99 return date($options['format'], time()); 100 } else if ($options['type'] == 'timestamp') { 101 return date($options['format'], time()); 97 98 if ($options['expression'] !== false && is_string($options['expression'])) { 99 return new Doctrine_Expression($options['expression']); 102 100 } else { 103 return time(); 101 if ($options['type'] == 'date') { 102 return date($options['format'], time()); 103 } else if ($options['type'] == 'timestamp') { 104 return date($options['format'], time()); 105 } else { 106 return time(); 107 } 104 108 } 105 109 } -
branches/0.10/lib/Doctrine/Template/Timestampable.php
r3676 r3682 40 40 * @var string 41 41 */ 42 protected $_options = array('created' => array('name' => 'created_at', 43 'type' => 'timestamp', 44 'format' => 'Y-m-d H:i:s', 45 'disabled' => false, 46 'options' => array()), 47 'updated' => array('name' => 'updated_at', 48 'type' => 'timestamp', 49 'format' => 'Y-m-d H:i:s', 50 'disabled' => false, 51 'onInsert' => true, 52 'options' => array())); 53 42 protected $_options = array('created' => array('name' => 'created_at', 43 'type' => 'timestamp', 44 'format' => 'Y-m-d H:i:s', 45 'disabled' => false, 46 'expression' => false, 47 'options' => array()), 48 'updated' => array('name' => 'updated_at', 49 'type' => 'timestamp', 50 'format' => 'Y-m-d H:i:s', 51 'disabled' => false, 52 'expression' => false, 53 'onInsert' => true, 54 'options' => array())); 55 54 56 /** 55 57 * __construct … … 62 64 $this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options); 63 65 } 64 66 65 67 /** 66 68 * setTableDefinition -
branches/0.9/lib/Doctrine/Template/Listener/Timestampable.php
r3676 r3682 39 39 */ 40 40 protected $_options = array(); 41 41 42 42 /** 43 43 * __construct … … 50 50 $this->_options = $options; 51 51 } 52 52 53 53 /** 54 54 * preInsert … … 69 69 } 70 70 } 71 71 72 72 /** 73 73 * preUpdate … … 78 78 public function preUpdate(Doctrine_Event $event) 79 79 { 80 if( !$this->_options['updated']['disabled']) {80 if( ! $this->_options['updated']['disabled']) { 81 81 $updatedName = $this->_options['updated']['name']; 82 82 $event->getInvoker()->$updatedName = $this->getTimestamp('updated'); 83 83 } 84 84 } 85 85 86 86 /** 87 87 * getTimestamp … … 95 95 { 96 96 $options = $this->_options[$type]; 97 98 if ($options['type'] == 'date') { 99 return date($options['format'], time()); 100 } else if ($options['type'] == 'timestamp') { 101 return date($options['format'], time()); 97 98 if ($options['expression'] !== false && is_string($options['expression'])) { 99 return new Doctrine_Expression($options['expression']); 102 100 } else { 103 return time(); 101 if ($options['type'] == 'date') { 102 return date($options['format'], time()); 103 } else if ($options['type'] == 'timestamp') { 104 return date($options['format'], time()); 105 } else { 106 return time(); 107 } 104 108 } 105 109 } -
branches/0.9/lib/Doctrine/Template/Timestampable.php
r3676 r3682 40 40 * @var string 41 41 */ 42 protected $_options = array('created' => array('name' => 'created_at', 43 'type' => 'timestamp', 44 'format' => 'Y-m-d H:i:s', 45 'disabled' => false, 46 'options' => array()), 47 'updated' => array('name' => 'updated_at', 48 'type' => 'timestamp', 49 'format' => 'Y-m-d H:i:s', 50 'disabled' => false, 51 'onInsert' => true, 52 'options' => array())); 53 42 protected $_options = array('created' => array('name' => 'created_at', 43 'type' => 'timestamp', 44 'format' => 'Y-m-d H:i:s', 45 'disabled' => false, 46 'expression' => false, 47 'options' => array()), 48 'updated' => array('name' => 'updated_at', 49 'type' => 'timestamp', 50 'format' => 'Y-m-d H:i:s', 51 'disabled' => false, 52 'expression' => false, 53 'onInsert' => true, 54 'options' => array())); 55 54 56 /** 55 57 * __construct … … 62 64 $this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options); 63 65 } 64 66 65 67 /** 66 68 * setTableDefinition