N°2293 - API OnDBUpdate and AfterUpdate need modified fields and previous data

- add a getter for the protected property DBObject::$m_aChanges
This commit is contained in:
bruno DA SILVA
2020-01-07 15:05:29 +01:00
parent cda18b950e
commit 2043010aad
2 changed files with 20 additions and 2 deletions

View File

@@ -421,7 +421,7 @@ interface iApplicationObjectExtension
* Invoked when an object is updated into the database. The method is called right <b>after</b> the object has been written to the
* database.
*
* Changes made to the object can be get using {@link $oObject::$m_aChanges}. Do not call {@link \DBObject::ListChanges} for this purpose !
* Changes made to the object can be get using {@link $oObject::ListChangesUpdated()}. Do not call {@link \DBObject::ListChanges} for this purpose because it will be empty as the object has already be written to DB!
*
* @param \cmdbAbstractObject $oObject The target object
* @param CMDBChange|null $oChange A change context. Since 2.0 it is fine to ignore it, as the framework does maintain this information
@@ -429,7 +429,7 @@ interface iApplicationObjectExtension
*
* @return void
*
* @since 2.7.0 N°2293 can access object changes by calling {@link $oObject::$m_aChanges}
* @since 2.7.0 N°2293 can access object changes by calling {@link $oObject::ListChangesUpdated()}
*/
public function OnDBUpdate($oObject, $oChange = null);

View File

@@ -2396,6 +2396,24 @@ abstract class DBObject implements iDisplay
}
}
/**
* List the changed attributes that were persisted by an update.
*
* @see \DBObject::ListChanges() use DBObject::ListChanges() if your code is BEFORE the update
*
* @return array
*/
public function ListChangesUpdated()
{
if (empty($this->m_aChanges))
{
return array();
}
return $this->m_aChanges;
}
/**
* Whether or not an object was modified since last read from the DB
* (ie: does it differ from the DB ?)