http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72720

Revision: 72720
Author:   jeroendedauw
Date:     2010-09-10 14:07:43 +0000 (Fri, 10 Sep 2010)

Log Message:
-----------
Changes for 0.4 - work on validation error handling

Modified Paths:
--------------
    trunk/extensions/Validator/includes/Validator.php

Modified: trunk/extensions/Validator/includes/Validator.php
===================================================================
--- trunk/extensions/Validator/includes/Validator.php   2010-09-10 14:01:34 UTC 
(rev 72719)
+++ trunk/extensions/Validator/includes/Validator.php   2010-09-10 14:07:43 UTC 
(rev 72720)
@@ -188,7 +188,7 @@
                        
                        }
                        else { // If the parameter is not found in the list of 
allowed ones, add an item to the $this->mErrors array.
-                               $this->registerError(
+                               $this->registerNewError(
                                        wfMsgExt(
                                                
'validator_error_unknown_argument',
                                                'parsemag',
@@ -209,16 +209,27 @@
         * @param mixed $tags string or array
         * @param integer $severity
         */
-       protected function registerError( $message, $tags = array(), $severity 
= ValidatorError::SEVERITY_NORMAL ) {
-               $error = new ValidatorError(
-                       $message,
-                       $severity,
-                       $this->element,
-                       (array)$tags
+       protected function registerNewError( $message, $tags = array(), 
$severity = ValidatorError::SEVERITY_NORMAL ) {
+               $this->registerError(
+                       new ValidatorError(
+                               $message,
+                               $severity,
+                               $this->element,
+                               (array)$tags
+                       )
                );
-               
+       }
+       
+       /**
+        * Registers an error.
+        * 
+        * @since 0.4
+        * 
+        * @param ValidationError $error
+        */
+       protected function registerError( ValidatorError $error ) {
                $this->errors[] = $error;
-               ValidatorErrorHandler::addError( $error );
+               ValidatorErrorHandler::addError( $error );              
        }
        
        /**
@@ -279,7 +290,9 @@
                        $parameter = $this->parameters[$paramName];
                        
                        if ( !$parameter->validate() ) {
-                               $this->errors = array_merge( $this->errors, 
$parameter->getErrors() );
+                               foreach ( $parameter->getErrors() as $error ) {
+                                       $this->registerError( $error );
+                               }
                        }
                }
        }



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to