Development

/branches/1.2/lib/plugins/sfDoctrinePlugin/lib/record/sfDoctrineRecordListener.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/plugins/sfDoctrinePlugin/lib/record/sfDoctrineRecordListener.class.php

Revision 11878, 1.3 kB (checked in by Jonathan.Wage, 6 years ago)

[1.2] sfDoctrinePlugin: Moving remaining files in to appropriate folders

  • Property svn:keywords set to Id Date Author Revision HeadURL
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  * (c) Jonathan H. Wage <jonwage@gmail.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 /**
13  * Default Doctrine_Record listener
14  *
15  * @package    symfony
16  * @subpackage doctrine
17  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
18  * @author     Jonathan H. Wage <jonwage@gmail.com>
19  * @version    SVN: $Id$
20  */
21 class sfDoctrineRecordListener extends Doctrine_Record_Listener
22 {
23   /**
24    * preInsert
25    *
26    * @param string $Doctrine_Event
27    * @return void
28    */
29   public function preInsert(Doctrine_Event $event)
30   {
31     if ($event->getInvoker()->getTable()->hasColumn('created_at'))
32     {
33       $event->getInvoker()->created_at = date('Y-m-d H:i:s', time());
34     }
35     
36     if ($event->getInvoker()->getTable()->hasColumn('updated_at'))
37     {
38       $event->getInvoker()->updated_at = date('Y-m-d H:i:s', time());
39     }
40   }
41  
42   /**
43    * preUpdate
44    *
45    * @param string $Doctrine_Event
46    * @return void
47    */
48   public function preUpdate(Doctrine_Event $event)
49   {
50     if ($event->getInvoker()->getTable()->hasColumn('updated_at'))
51     {
52       $event->getInvoker()->updated_at = date('Y-m-d H:i:s', time());
53     }
54   }
55 }
Note: See TracBrowser for help on using the browser.