*/
class EmailValidatorFilter extends BaseFrameworkSystem implements Filterable {
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
/**
* Check wether the email as already been taken
*
- * @param $email Email to check for existence
+ * @param $email Email to check for existence
* @return $alreadyTaken Wether the email has been taken
*/
private function ifEmailIsTaken ($email) {
// Default is already taken
$alreadyTaken = true;
- $this->partialStub(sprintf("Email: %s", $email));
+
+ // Get a registry instance
+ $registry = Registry::getInstance();
+
+ // Is the user already there?
+ if ($registry->keyExists('userInstance')) {
+ // Use the instance for checking for the email
+ $userInstance = $registry->getInstance('userInstance');
+ $userInstance->setEmailAddress($email);
+ } else {
+ // If this instance is created then the username *does* exist
+ $userInstance = User::createUserByEmail($userName);
+
+ // Remember this user instance in our registry for later usage
+ $registry->addInstance('userInstance', $userInstance);
+ }
+
+ // Does the email exist?
+ if (!$userInstance->ifEmailAddressExists()) {
+ // This email has not being used yet
+ $alreadyTaken = false;
+ }
// Return the result
return $alreadyTaken;