Changeset 3682

Show
Ignore:
Timestamp:
01/30/08 01:04:54 (17 months ago)
Author:
guilhermeblanco
Message:

Merged changeset #3577 into 0.9 and 0.10 branches

Location:
branches
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/0.10/lib/Doctrine/Template/Listener/Timestampable.php

    r3676 r3682  
    3939     */ 
    4040    protected $_options = array(); 
    41      
     41 
    4242    /** 
    4343     * __construct 
     
    5050        $this->_options = $options; 
    5151    } 
    52      
     52 
    5353    /** 
    5454     * preInsert 
     
    6969        } 
    7070    } 
    71      
     71 
    7272    /** 
    7373     * preUpdate 
     
    8383        } 
    8484    } 
    85      
     85 
    8686    /** 
    8787     * getTimestamp 
     
    9595    { 
    9696        $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']); 
    102100        } 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            } 
    104108        } 
    105109    } 
  • branches/0.10/lib/Doctrine/Template/Timestampable.php

    r3676 r3682  
    4040     * @var string 
    4141     */ 
    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 
    5456    /** 
    5557     * __construct 
     
    6264        $this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options); 
    6365    } 
    64      
     66 
    6567    /** 
    6668     * setTableDefinition 
  • branches/0.9/lib/Doctrine/Template/Listener/Timestampable.php

    r3676 r3682  
    3939     */ 
    4040    protected $_options = array(); 
    41      
     41 
    4242    /** 
    4343     * __construct 
     
    5050        $this->_options = $options; 
    5151    } 
    52      
     52 
    5353    /** 
    5454     * preInsert 
     
    6969        } 
    7070    } 
    71      
     71 
    7272    /** 
    7373     * preUpdate 
     
    7878    public function preUpdate(Doctrine_Event $event) 
    7979    { 
    80         if(!$this->_options['updated']['disabled']) { 
     80        if( ! $this->_options['updated']['disabled']) { 
    8181            $updatedName = $this->_options['updated']['name']; 
    8282            $event->getInvoker()->$updatedName = $this->getTimestamp('updated'); 
    8383        } 
    8484    } 
    85      
     85 
    8686    /** 
    8787     * getTimestamp 
     
    9595    { 
    9696        $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']); 
    102100        } 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            } 
    104108        } 
    105109    } 
  • branches/0.9/lib/Doctrine/Template/Timestampable.php

    r3676 r3682  
    4040     * @var string 
    4141     */ 
    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 
    5456    /** 
    5557     * __construct 
     
    6264        $this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options); 
    6365    } 
    64      
     66 
    6567    /** 
    6668     * setTableDefinition