【发布时间】:2011-04-14 01:32:19
【问题描述】:
我正在编写一个 symfony 1.4 应用程序,并试图设置在编辑对象时特定值发生变化时运行的代码。
我试图在模型类中而不是在视图中执行此操作,因为这将在保存此对象时应用。
有没有办法在用户进行任何更改之前访问对象的原始值?
注意:
对象尚未保存,因此仍然可以(以某种方式)检索原始值。
代码:
public function save()
{
if($this->isNew())
$this->getAcctRelatedByAccountId()->updateCurrentBalance(($this->isAdditive()) ? $this->getAmount(): $this->getAmount()*-1);
// get the original value HERE
// do work based on the original value
// do work based on the new, submitted value
return parent::save();
}
【问题讨论】:
标签: php symfony1 symfony-1.4 overloading