From: Roland Häder Date: Wed, 11 Mar 2009 03:27:05 +0000 (+0000) Subject: All filters rewritten to throw FilterChainException X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bfb4fbd86ac6561ce9ac7160e6ef05b1653c1e6a;p=core.git All filters rewritten to throw FilterChainException --- diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 5cc9d811..acea78de 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -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 diff --git a/inc/classes/main/filter/class_FilterChain.php b/inc/classes/main/filter/class_FilterChain.php index 9e22ee9f..44777264 100644 --- a/inc/classes/main/filter/class_FilterChain.php +++ b/inc/classes/main/filter/class_FilterChain.php @@ -73,13 +73,13 @@ class FilterChain extends BaseFrameworkSystem { */ public function processFilters (Requestable $requestInstance, Responseable $responseInstance) { // Run all filters - //* DEBUG */ echo "COUNT=".count($this->filters)."
\n"; + /* DEBUG */ echo "COUNT=".count($this->filters)."
\n"; foreach ($this->filters as $filterInstance) { // Try to execute this filter try { - //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing started.
\n"; + /* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing started.
\n"; $filterInstance->execute($requestInstance, $responseInstance); - //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing ended.
\n"; + /* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing ended.
\n"; } catch (FilterChainException $e) { // This exception can be thrown to just skip any further processing break; diff --git a/inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php b/inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php index 2439cb56..38891e5e 100644 --- a/inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php +++ b/inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php @@ -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); } } } diff --git a/inc/classes/main/filter/validator/class_EmailValidatorFilter.php b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php index fe09faad..9dabfc39 100644 --- a/inc/classes/main/filter/validator/class_EmailValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php @@ -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 } diff --git a/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php b/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php index 3bb5ecb9..ba39cdac 100644 --- a/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php @@ -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 } } diff --git a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php index 81ff5319..90950682 100644 --- a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php +++ b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php @@ -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); } } diff --git a/inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php b/inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php index 35f38cee..95aea2b7 100644 --- a/inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php @@ -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'); diff --git a/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php b/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php index 8f426404..e8e55c43 100644 --- a/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php @@ -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 diff --git a/inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php b/inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php index d4c3bfd9..dda9a2e3 100644 --- a/inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php @@ -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); } } } diff --git a/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php b/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php index 309371c5..d924c5b8 100644 --- a/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php @@ -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); } } } diff --git a/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php index 51c2e6f3..b6ad60b0 100644 --- a/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php @@ -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 diff --git a/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php index 82d1eeb9..32f0aa2a 100644 --- a/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php +++ b/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php @@ -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); } } diff --git a/inc/classes/main/registry/class_Registry.php b/inc/classes/main/registry/class_Registry.php index 243c2b49..d5ad6e6b 100644 --- a/inc/classes/main/registry/class_Registry.php +++ b/inc/classes/main/registry/class_Registry.php @@ -1,6 +1,7 @@ * @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;