Development

/branches/1.3/lib/plugins/sfPropelPlugin/lib/behavior/SfPropelBehaviorTimestampable.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/plugins/sfPropelPlugin/lib/behavior/SfPropelBehaviorTimestampable.php

Revision 23310, 1.3 kB (checked in by Kris.Wallsmith, 5 years ago)

[1.3] added copyright notices to propel behaviors, remove some unneeded generated methods

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * A timestampable implementation BC with symfony <= 1.2.
13  *
14  * @package     sfPropelPlugin
15  * @subpackage  behavior
16  * @author      Kris Wallsmith <kris.wallsmith@symfony-project.com>
17  * @version     SVN: $Id$
18  */
19 class SfPropelBehaviorTimestampable extends SfPropelBehaviorBase
20 {
21   protected $parameters = array(
22     'create_column' => null,
23     'update_column' => null,
24   );
25
26   public function preInsert()
27   {
28     if ($this->isDisabled())
29     {
30       return;
31     }
32
33     if ($column = $this->getParameter('create_column'))
34     {
35       return <<<EOF
36 if (!\$this->isColumnModified({$this->getTable()->getColumn($column)->getConstantName()}))
37 {
38   \$this->set{$this->getTable()->getColumn($column)->getPhpName()}(time());
39 }
40
41 EOF;
42     }
43   }
44
45   public function preSave()
46   {
47     if ($this->isDisabled())
48     {
49       return;
50     }
51
52     if ($column = $this->getParameter('update_column'))
53     {
54       return <<<EOF
55 if (\$this->isModified() && !\$this->isColumnModified({$this->getTable()->getColumn($column)->getConstantName()}))
56 {
57   \$this->set{$this->getTable()->getColumn($column)->getPhpName()}(time());
58 }
59
60 EOF;
61     }
62   }
63 }
64
Note: See TracBrowser for help on using the browser.