]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/filter/validator/class_EmailValidatorFilter.php
Continued:
[core.git] / framework / main / classes / filter / validator / class_EmailValidatorFilter.php
index d609d86573c4a2c15700dac7a0534e00c62da0fa..01b631d61eba5bdbd962f6437d6eb263b4d6d5dd 100644 (file)
@@ -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 <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 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?