|
Revision 23310, 1.3 kB
(checked in by Kris.Wallsmith, 3 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 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 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 |
|
|---|