We want to use $this->changes() to trigger some business logic when editing/saving domain objects (using before/afterSave hooks). We found that we can't use the changes() method to find out whether properties were changed.
The changes() method does not really reflect changes to the domainObject, because any prop that was touched is returned, even it's was not actually changed (a more appropriate name would be touched()).
We propose changing the set() method to only add properties to $this->_changed[] when they were actually changed.
So change this:
/**
* Sets a property
*/
public function set($prop, $value)
{
$this->_data[$prop] = $value;
$this->_changed[] = $prop;
return $this;
}
into this:
/**
* Sets a property
*/
public function set($prop, $value)
{
if($this->_data[$prop] != $value)
{
$this->_data[$prop] = $value;
$this->_changed[] = $prop;
}
return $this;
}
We want to use $this->changes() to trigger some business logic when editing/saving domain objects (using before/afterSave hooks). We found that we can't use the changes() method to find out whether properties were changed.
The changes() method does not really reflect changes to the domainObject, because any prop that was touched is returned, even it's was not actually changed (a more appropriate name would be touched()).
We propose changing the set() method to only add properties to $this->_changed[] when they were actually changed.
So change this:
into this: