Add new method getCustomerByEmail into CustomerQuery
This commit is contained in:
@@ -111,7 +111,7 @@ class CustomerCreateForm extends AddressCreateForm
|
||||
|
||||
public function verifyExistingEmail($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$customer = CustomerQuery::create()->findOneByEmail($value);
|
||||
$customer = CustomerQuery::getCustomerByEmail($value);
|
||||
if ($customer) {
|
||||
$context->addViolation("This email already exists.");
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class CustomerProfilUpdateForm extends CustomerCreateForm
|
||||
*/
|
||||
public function verifyExistingEmail($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$customer = CustomerQuery::create()->findOneByEmail($value);
|
||||
$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("This email already exists.");
|
||||
|
||||
@@ -17,4 +17,8 @@ use Thelia\Model\Base\CustomerQuery as BaseCustomerQuery;
|
||||
*/
|
||||
class CustomerQuery extends BaseCustomerQuery {
|
||||
|
||||
public static function getCustomerByEmail($email)
|
||||
{
|
||||
return self::create()->findOneByEmail($email);
|
||||
}
|
||||
} // CustomerQuery
|
||||
|
||||
Reference in New Issue
Block a user