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;
*
* @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
*
*
* @return void
*/
- protected function __construct () {
+ private function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
}
$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');
// 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');
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');
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
+ }
}
/**
* @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;
$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?