Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

APICHANGE: add validation extension hook to DataExtension

  • Loading branch information...
commit 42e6ae2cdfa625a29111c3b314d2c9a5710ee90e 1 parent cde9b31
Mateusz U mateusz authored
Showing with 13 additions and 2 deletions.
  1. +9 −0 model/DataExtension.php
  2. +4 −2 model/DataObject.php
9 model/DataExtension.php
View
@@ -63,6 +63,15 @@ static function add_to_class($class, $extensionClass, $args = null) {
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
6 model/DataObject.php
View
@@ -883,7 +883,7 @@ public function forceChange() {
* 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 @@ public function forceChange() {
* @return A {@link ValidationResult} object
*/
protected function validate() {
- return new ValidationResult();
+ $result = new ValidationResult();
+ $this->extend('validate', $result);
+ return $result;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.