All filters rewritten to throw FilterChainException
[core.git] / inc / classes / main / filter / validator / class_EmailValidatorFilter.php
index 6183b33b265066b17fe5d9cf5babaa7e86e3b599..9dabfc3937faed3ad3e1858c0f8efc9dfbf34cb3 100644 (file)
@@ -7,7 +7,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright  Copyright (c) 2007 - 2009 Roland Haeder, this is free software
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -38,16 +38,12 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
        /**
         * Creates an instance of this filter class
         *
        /**
         * Creates an instance of this filter class
         *
-        * @param       $controllerInstance             An instance of a Controller class
         * @return      $filterInstance                 An instance of this filter class
         */
         * @return      $filterInstance                 An instance of this filter class
         */
-       public final static function createEmailValidatorFilter (Controller $controllerInstance) {
+       public final static function createEmailValidatorFilter () {
                // Get a new instance
                $filterInstance = new EmailValidatorFilter();
 
                // Get a new instance
                $filterInstance = new EmailValidatorFilter();
 
-               // Set the controller
-               $filterInstance->setControllerInstance($controllerInstance);
-
                // Return the instance
                return $filterInstance;
        }
                // Return the instance
                return $filterInstance;
        }
@@ -58,6 +54,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
         * @param       $requestInstance        An instance of a class with an Requestable interface
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
+        * @throws      FilterChainException    If this filter fails to operate
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get Email from request
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get Email from request
@@ -78,7 +75,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                                $responseInstance->addFatalMessage('email_unset');
 
                                // Abort here
                                $responseInstance->addFatalMessage('email_unset');
 
                                // Abort here
-                               return false;
+                               throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                        } elseif ((empty($email1)) || (empty($email2))) {
                                // Email is empty
                                $requestInstance->requestIsValid(false);
                        } elseif ((empty($email1)) || (empty($email2))) {
                                // Email is empty
                                $requestInstance->requestIsValid(false);
@@ -96,7 +93,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                                } // END - if
 
                                // Abort here
                                } // END - if
 
                                // Abort here
-                               return false;
+                               throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                        } elseif ($this->ifEmailIsTaken($email1)) {
                                // Email is already taken
                                $requestInstance->requestIsValid(false);
                        } elseif ($this->ifEmailIsTaken($email1)) {
                                // Email is already taken
                                $requestInstance->requestIsValid(false);
@@ -105,7 +102,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                                $responseInstance->addFatalMessage('email_taken');
 
                                // Abort here
                                $responseInstance->addFatalMessage('email_taken');
 
                                // Abort here
-                               return false;
+                               throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                        } elseif ($email1 != $email2) {
                                // Emails didn't match
                                $requestInstance->requestIsValid(false);
                        } elseif ($email1 != $email2) {
                                // Emails didn't match
                                $requestInstance->requestIsValid(false);
@@ -114,7 +111,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                                $responseInstance->addFatalMessage('emails_mismatch');
 
                                // Abort here
                                $responseInstance->addFatalMessage('emails_mismatch');
 
                                // Abort here
-                               return false;
+                               throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                        } // END - elseif
                } elseif (empty($email)) {
                        // Empty field!
                        } // END - elseif
                } elseif (empty($email)) {
                        // Empty field!
@@ -124,7 +121,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('email_empty');
 
                        // Abort here
                        $responseInstance->addFatalMessage('email_empty');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } // END - elseif
        }
 
                } // END - elseif
        }