X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Ffilter%2Fvalidator%2Fclass_EmailValidatorFilter.php;h=01b631d61eba5bdbd962f6437d6eb263b4d6d5dd;hb=HEAD;hp=e9f8aa478d50b85c32077a2ff88448d1a6211e0c;hpb=f57dd51863ec9baacba447d76b46d5c709b9b02e;p=core.git diff --git a/framework/main/classes/filter/validator/class_EmailValidatorFilter.php b/framework/main/classes/filter/validator/class_EmailValidatorFilter.php index e9f8aa47..01b631d6 100644 --- a/framework/main/classes/filter/validator/class_EmailValidatorFilter.php +++ b/framework/main/classes/filter/validator/class_EmailValidatorFilter.php @@ -3,9 +3,11 @@ namespace Org\Mxchange\CoreFramework\Filter\Validator\Email; // Import framework stuff +use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Filter\BaseFilter; +use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException; use Org\Mxchange\CoreFramework\Filter\Filterable; -use Org\Mxchange\CoreFramework\Registry\GenericRegistry; +use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Response\Responseable; @@ -17,7 +19,7 @@ use Org\Mxchange\CoreFramework\Response\Responseable; * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2019 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -40,7 +42,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { * * @return void */ - protected function __construct () { + private function __construct () { // Call parent constructor parent::__construct(__CLASS__); } @@ -71,7 +73,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { $email = $requestInstance->getRequestElement('email'); // Is the Email set? - if ((is_null($email)) || ($this->getConfigInstance()->getConfigEntry('register_email_unique') == 'Y')) { + if ((is_null($email)) || (FrameworkBootstrap::getConfigurationInstance()->isEnabled('register_email_unique'))) { // Try it again $email1 = $requestInstance->getRequestElement('email1'); $email2 = $requestInstance->getRequestElement('email2'); @@ -79,7 +81,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { // Is the email still not set? if ((is_null($email1)) || (is_null($email2))) { // Not found in form so stop the filtering process - $requestInstance->requestIsValid(false); + $requestInstance->setIsRequestValid(FALSE); // Add a message to the response $responseInstance->addFatalMessage('email_unset'); @@ -88,25 +90,25 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); } elseif ((empty($email1)) || (empty($email2))) { // Email is empty - $requestInstance->requestIsValid(false); + $requestInstance->setIsRequestValid(FALSE); // Is the email empty? if (empty($email1)) { // Add a message to the response $responseInstance->addFatalMessage('email1_empty'); - } // END - if + } // Is the confirmation empty? if (empty($email2)) { // Add a message to the response $responseInstance->addFatalMessage('email2_empty'); - } // END - if + } // Abort here throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); } elseif ($this->ifEmailIsTaken($email1)) { // Email is already taken - $requestInstance->requestIsValid(false); + $requestInstance->setIsRequestValid(FALSE); // Add a message to the response $responseInstance->addFatalMessage('email_taken'); @@ -115,24 +117,24 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); } elseif ($email1 != $email2) { // Emails didn't match - $requestInstance->requestIsValid(false); + $requestInstance->setIsRequestValid(FALSE); // Add a message to the response $responseInstance->addFatalMessage('emails_mismatch'); // Abort here throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - elseif + } } elseif (empty($email)) { // Empty field! - $requestInstance->requestIsValid(false); + $requestInstance->setIsRequestValid(FALSE); // Add a message to the response $responseInstance->addFatalMessage('email_empty'); // Abort here throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - elseif + } } /** @@ -141,7 +143,7 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { * @param $email Email to check for existence * @return $alreadyTaken Whether the email has been taken */ - private function ifEmailIsTaken ($email) { + private function ifEmailIsTaken (string $email) { // Default is already taken $alreadyTaken = true; @@ -149,19 +151,19 @@ class EmailValidatorFilter extends BaseFilter implements Filterable { $userInstance = NULL; // Get a registry instance - $registry = GenericRegistry::getRegistry(); + $registryInstance = ObjectRegistry::getRegistry('generic'); // Is the user already there? - if ($registry->instanceExists('user')) { + if ($registryInstance->instanceExists('user')) { // Use the instance for checking for the email - $userInstance = $registry->getInstance('user'); + $userInstance = $registryInstance->getInstance('user'); $userInstance->setEmailAddress($email); } else { // If this instance is created then the username *does* exist - $userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('user_class'), 'createMemberByEmail'), array($email)); + $userInstance = call_user_func_array(array(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_class'), 'createMemberByEmail'), array($email)); // Remember this user instance in our registry for later usage - $registry->addInstance('user', $userInstance); + $registryInstance->addInstance('user', $userInstance); } // Does the email exist?