public function verifyExistingEmail($value, ExecutionContextInterface $context) { $customer = CustomerQuery::getCustomerByEmail($value); if ($customer) { $context->addViolation(Translator::getInstance()->trans("This email already exists.")); } }
/** * @param $value * @param ExecutionContextInterface $context */ public function verifyExistingEmail($value, ExecutionContextInterface $context) { $customer = CustomerQuery::getCustomerByEmail($value); // If there is already a customer for this email address and if the customer is different from the current user, do a violation if ($customer && $customer->getId() != $this->getRequest()->getSession()->getCustomerUser()->getId()) { $context->addViolation(Translator::getInstance()->trans("This email already exists.")); } }