]> git.mxchange.org Git - core.git/commitdiff
All filters rewritten to throw FilterChainException
authorRoland Häder <roland@mxchange.org>
Wed, 11 Mar 2009 03:27:05 +0000 (03:27 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 11 Mar 2009 03:27:05 +0000 (03:27 +0000)
13 files changed:
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/filter/class_FilterChain.php
inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php
inc/classes/main/filter/validator/class_EmailValidatorFilter.php
inc/classes/main/filter/validator/class_PasswordValidatorFilter.php
inc/classes/main/filter/validator/class_UserNameValidatorFilter.php
inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php
inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php
inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php
inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php
inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php
inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php
inc/classes/main/registry/class_Registry.php

index 5cc9d8119df991d6803ba38a42f5dbc79fdc9ed9..acea78ded4ebb8c49137d5e5648f86ea11c55906 100644 (file)
@@ -149,6 +149,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        const EXCEPTION_ASSERTION_FAILED             = 0x037;
        const EXCEPTION_FILE_CANNOT_BE_READ          = 0x038;
        const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x039;
+       const EXCEPTION_FILTER_CHAIN_INTERCEPTED     = 0x040;
 
        /**
         * In the super constructor these system classes shall be ignored or else
@@ -175,7 +176,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        );
 
        /**
-        * Private super constructor
+        * Protected super constructor
         *
         * @param       $className      Name of the class
         * @return      void
index 9e22ee9f9701c2c2b261b04f422a5988cf75e8c1..447772648b01454cfca393573ca9288dd4b9ec3f 100644 (file)
@@ -73,13 +73,13 @@ class FilterChain extends BaseFrameworkSystem {
         */
        public function processFilters (Requestable $requestInstance, Responseable $responseInstance) {
                // Run all filters
-               //* DEBUG */ echo "COUNT=".count($this->filters)."<br />\n";
+               /* DEBUG */ echo "COUNT=".count($this->filters)."<br />\n";
                foreach ($this->filters as $filterInstance) {
                        // Try to execute this filter
                        try {
-                               //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing started.<br />\n";
+                               /* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing started.<br />\n";
                                $filterInstance->execute($requestInstance, $responseInstance);
-                               //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing ended.<br />\n";
+                               /* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing ended.<br />\n";
                        } catch (FilterChainException $e) {
                                // This exception can be thrown to just skip any further processing
                                break;
index 2439cb56406106274178c126ae939813301ba5da..38891e5eb0b38788ed2a8cfbbd413304dd393115 100644 (file)
@@ -95,6 +95,7 @@ class PaymentDiscoveryFilter extends BaseFilter implements Filterable {
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
         * @todo        0% done
+        * @throws      FilterChainException    If this filter fails to operate
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Try to get real discovery class
@@ -116,7 +117,7 @@ class PaymentDiscoveryFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessagePlain($e->getMessage());
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } catch (ClassNotFoundException $e) {
                        // Something bad happend
                        $requestInstance->requestIsValid(false);
@@ -126,7 +127,7 @@ class PaymentDiscoveryFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessagePlain($e->getMessage());
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                }
        }
 }
index fe09faade3bd86eb5d44be2552d9acdbd3c48f54..9dabfc3937faed3ad3e1858c0f8efc9dfbf34cb3 100644 (file)
@@ -54,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
+        * @throws      FilterChainException    If this filter fails to operate
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get Email from request
@@ -74,7 +75,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                                $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);
@@ -92,7 +93,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                                } // 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);
@@ -101,7 +102,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                                $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);
@@ -110,7 +111,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                                $responseInstance->addFatalMessage('emails_mismatch');
 
                                // Abort here
-                               return false;
+                               throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                        } // END - elseif
                } elseif (empty($email)) {
                        // Empty field!
@@ -120,7 +121,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('email_empty');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } // END - elseif
        }
 
index 3bb5ecb9e2a40dbed295d35d06b1c0f64e2d7286..ba39cdacab44333387c405b93dc5dffa5b74caca 100644 (file)
@@ -52,6 +52,7 @@ class PasswordValidatorFilter 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
+        * @throws      FilterChainException    If this filter fails to operate
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get passwords
@@ -67,7 +68,7 @@ class PasswordValidatorFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('password_unset');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } elseif ((empty($password1)) || (empty($password2))) {
                        // Password is empty
                        $requestInstance->requestIsValid(false);
@@ -85,7 +86,7 @@ class PasswordValidatorFilter extends BaseFilter implements Filterable {
                        } // END - if
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } elseif ($password1 != $password2) {
                        // Passwords didn't match
                        $requestInstance->requestIsValid(false);
@@ -94,7 +95,7 @@ class PasswordValidatorFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('pass_mismatch');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } // END - elseif
        }
 }
index 81ff5319d811650cf24328f6e8ba24e6244a9688..909506822627a70bf2cc886857867bc81fd007ca 100644 (file)
@@ -53,6 +53,7 @@ class UserNameValidatorFilter 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
+        * @throws      FilterChainException    If this filter fails to operate
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get username from request
@@ -67,7 +68,7 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('username_unset');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } elseif (empty($userName)) {
                        // Empty field!
                        $requestInstance->requestIsValid(false);
@@ -76,7 +77,7 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('username_empty');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } elseif ($this->ifUserNameIsTaken($userName)) {
                        // Username is already taken
                        $requestInstance->requestIsValid(false);
@@ -85,7 +86,7 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('username_taken');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                }
        }
 
index 35f38cee37dbb0c1e1e80a11d72df1857ef7a3cb..95aea2b7ff7bd9ded9e5bb12a37c39b6e7c69e30 100644 (file)
@@ -53,6 +53,7 @@ class AccountPasswordVerifierFilter extends BaseFilter implements Filterable {
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
         * @throws      AccountPasswordMismatchException        If the account password does not match
+        * @throws      FilterChainException                            If this filter fails to operate
         * @todo        Rewrite handling of different password fields
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
@@ -73,7 +74,7 @@ class AccountPasswordVerifierFilter extends BaseFilter implements Filterable {
                                $responseInstance->addFatalMessage('password_unset');
 
                                // Abort here
-                               return false;
+                               throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                        } // END - if
                } // END - if
 
@@ -85,8 +86,8 @@ class AccountPasswordVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('password_empty');
 
                        // Abort here
-                       return false;
-               }
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+               } // END - if
 
                // Get a user instance
                $userInstance = Registry::getRegistry()->getInstance('user');
index 8f4264041effdaca4a67caf40ae50b4f0053ac0c..e8e55c439603522572d77acef8f13c6cbfb2e041 100644 (file)
@@ -52,6 +52,7 @@ class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable {
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
         * @throws      NullPointerException    If the user instance from registry is null
+        * @throws      FilterChainException    If this filter fails to operate
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get confirmation code from request
@@ -66,7 +67,7 @@ class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('confirm_code_unset');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } elseif (empty($confirmCode)) {
                        // Email is empty
                        $requestInstance->requestIsValid(false);
@@ -75,7 +76,7 @@ class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('confirm_code_empty');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                }
 
                // Get a user instance from registry
index d4c3bfd9184321877bc06514de3e60510f55bda9..dda9a2e3b21551cfeb16db35994e57e201cef1e1 100644 (file)
@@ -52,6 +52,7 @@ class PasswordGuestVerifierFilter 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
+        * @throws      FilterChainException    If this filter fails to operate
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get password
@@ -66,7 +67,7 @@ class PasswordGuestVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('password_unset');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } elseif (empty($password)) {
                        // Password is empty
                        $requestInstance->requestIsValid(false);
@@ -75,7 +76,7 @@ class PasswordGuestVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('password_empty');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                }
        }
 }
index 309371c5bb6e0c95ef30d3883a5f7795b0d36cbc..d924c5b819d592ff35e87cce1fca912237626cb2 100644 (file)
@@ -52,6 +52,7 @@ class PasswordVerifierFilter 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
+        * @throws      FilterChainException    If this filter fails to operate
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get password
@@ -66,7 +67,7 @@ class PasswordVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('password_unset');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } elseif (empty($password)) {
                        // Password is empty
                        $requestInstance->requestIsValid(false);
@@ -75,7 +76,7 @@ class PasswordVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('password_empty');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                }
        }
 }
index 51c2e6f3a708620f65d1a10f9707327705d13014..b6ad60b083eb67836a4e6fcff33075f2be284d60 100644 (file)
@@ -53,6 +53,7 @@ class UserGuestVerifierFilter 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
+        * @throws      FilterChainException    If this filter fails to operate
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get username from request
@@ -67,7 +68,7 @@ class UserGuestVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('username_guest_unset');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } elseif (empty($userName)) {
                        // Empty field!
                        $requestInstance->requestIsValid(false);
@@ -76,7 +77,7 @@ class UserGuestVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('username_guest_empty');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } elseif ($this->ifUserGuestIsTaken($userName) === false) {
                        // Username is already taken
                        $requestInstance->requestIsValid(false);
@@ -85,7 +86,7 @@ class UserGuestVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('username_guest_not_found');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                }
 
                // Set the element for compatiblity reasons
index 82d1eeb9438b4e9f2c1d055f6dc2a4a11c63d4e7..32f0aa2ad9f0b5158fcf86f86b1b06ac1f98b848 100644 (file)
@@ -53,6 +53,7 @@ class UserNameVerifierFilter 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
+        * @throws      FilterChainException    If this filter fails to operate
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Get username from request
@@ -67,7 +68,7 @@ class UserNameVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('username_unset');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } elseif (empty($userName)) {
                        // Empty field!
                        $requestInstance->requestIsValid(false);
@@ -76,7 +77,7 @@ class UserNameVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('username_empty');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                } elseif ($this->ifUserNameIsTaken($userName) === false) {
                        // Username is already taken
                        $requestInstance->requestIsValid(false);
@@ -85,7 +86,7 @@ class UserNameVerifierFilter extends BaseFilter implements Filterable {
                        $responseInstance->addFatalMessage('username_not_found');
 
                        // Abort here
-                       return false;
+                       throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
                }
        }
 
index 243c2b49f5ad44488ee5792dae58a143371d54b3..d5ad6e6bb882a69baa697722107c0d31ec76c47f 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 /**
- * A registry for several data types
+ * A registry for several data types and objects. Objects should be added by
+ * addInstance() and therefore must implement the interface Registerable.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -62,7 +63,7 @@ class Registry extends BaseFrameworkSystem implements Register {
                if (is_null(self::$registryInstance)) {
                        // Not yet, so create one
                        self::$registryInstance = new Registry();
-               }
+               } // END - if
 
                // Return the instance
                return self::$registryInstance;
@@ -126,7 +127,7 @@ class Registry extends BaseFrameworkSystem implements Register {
                // Is the instance there?
                if ($this->instanceExists($instanceKey)) {
                        $objectInstance = $this->instanceRegistry[$instanceKey];
-               }
+               } // END - if
 
                // Return the result
                return $objectInstance;