APICHANGE: add validation extension hook to DataExtension

This commit is contained in:
Mateusz Uzdowski 2012-04-13 16:18:06 +12:00
parent cde9b3183b
commit 42e6ae2cdf
2 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -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;
}
/**