mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
DataObject on*() callbacks now consistently invoke on subclasses as well
Before this was only possible for some specific ones, like onBeforeWrite. This excludes any callbacks with augment*() or update*() naming, since these are assumed to be on extension only, with a corresponding base method available on the class itself (e.g. "updateCMSFields()" vs "getCMSFields()").
This commit is contained in:
parent
18c9a95996
commit
d289016bc3
@ -423,12 +423,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
$clone = new $className( $this->toMap(), false, $this->model );
|
||||
$clone->ID = 0;
|
||||
|
||||
$clone->extend('onBeforeDuplicate', $this, $doWrite);
|
||||
$clone->invokeWithExtensions('onBeforeDuplicate', $this, $doWrite);
|
||||
if($doWrite) {
|
||||
$clone->write();
|
||||
$this->duplicateManyManyRelations($this, $clone);
|
||||
}
|
||||
$clone->extend('onAfterDuplicate', $this, $doWrite);
|
||||
$clone->invokeWithExtensions('onAfterDuplicate', $this, $doWrite);
|
||||
|
||||
return $clone;
|
||||
}
|
||||
@ -1065,7 +1065,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
|
||||
if($writeException) {
|
||||
// Used by DODs to clean up after themselves, eg, Versioned
|
||||
$this->extend('onAfterSkippedWrite');
|
||||
$this->invokeWithExtensions('onAfterSkippedWrite');
|
||||
throw $writeException;
|
||||
return false;
|
||||
}
|
||||
@ -1208,7 +1208,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
} elseif ( $showDebug ) {
|
||||
echo "<b>Debug:</b> no changes for DataObject<br />";
|
||||
// Used by DODs to clean up after themselves, eg, Versioned
|
||||
$this->extend('onAfterSkippedWrite');
|
||||
$this->invokeWithExtensions('onAfterSkippedWrite');
|
||||
}
|
||||
|
||||
// Clears the cache for this object so get_one returns the correct object.
|
||||
@ -1220,7 +1220,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
$this->record['LastEdited'] = SS_Datetime::now()->Rfc2822();
|
||||
} else {
|
||||
// Used by DODs to clean up after themselves, eg, Versioned
|
||||
$this->extend('onAfterSkippedWrite');
|
||||
$this->invokeWithExtensions('onAfterSkippedWrite');
|
||||
}
|
||||
|
||||
// Write relations as necessary
|
||||
|
Loading…
Reference in New Issue
Block a user