Browse Source

Merge pull request #11378 from cakephp/fix-validator-const

Allow for custom buildValidator event while keeping things BC.
Mark Story 8 years ago
parent
commit
142520cd77
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/Validation/ValidatorAwareTrait.php

+ 2 - 1
src/Validation/ValidatorAwareTrait.php

@@ -173,7 +173,8 @@ trait ValidatorAwareTrait
         $validator = new $this->_validatorClass;
         $validator = $this->$method($validator);
         if ($this instanceof EventDispatcherInterface) {
-            $this->dispatchEvent('Model.buildValidator', compact('validator', 'name'));
+            $event = defined(self::class . '::BUILD_VALIDATOR_EVENT') ? self::BUILD_VALIDATOR_EVENT : 'Model.buildValidator';
+            $this->dispatchEvent($event, compact('validator', 'name'));
         }
 
         if (!$validator instanceof Validator) {