mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
APICHANGE: add validation extension hook to DataExtension
This commit is contained in:
parent
cde9b3183b
commit
42e6ae2cdf
@ -63,6 +63,15 @@ abstract class DataExtension extends Extension {
|
||||
public static function unload_extra_statics($class, $extension) {
|
||||
throw new Exception('unload_extra_statics gone');
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for extension-specific validation.
|
||||
*
|
||||
* @param $validationResult Local validation result
|
||||
* @throws ValidationException
|
||||
*/
|
||||
function validate(ValidationResult &$validationResult) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit the given query object to support queries for this extension
|
||||
|
@ -883,7 +883,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* Validate the current object.
|
||||
*
|
||||
* By default, there is no validation - objects are always valid! However, you can overload this method in your
|
||||
* DataObject sub-classes to specify custom validation.
|
||||
* DataObject sub-classes to specify custom validation, or use the hook through DataExtension.
|
||||
*
|
||||
* Invalid objects won't be able to be written - a warning will be thrown and no write will occur. onBeforeWrite()
|
||||
* and onAfterWrite() won't get called either.
|
||||
@ -894,7 +894,9 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @return A {@link ValidationResult} object
|
||||
*/
|
||||
protected function validate() {
|
||||
return new ValidationResult();
|
||||
$result = new ValidationResult();
|
||||
$this->extend('validate', $result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user