From 5c5861aa2eaba976df740f8d376a4c450c0b1421 Mon Sep 17 00:00:00 2001 From: touffies Date: Wed, 23 Oct 2013 20:28:41 +0200 Subject: [PATCH] Add new method getCustomerByEmail into CustomerQuery --- core/lib/Thelia/Form/CustomerCreateForm.php | 2 +- core/lib/Thelia/Form/CustomerProfilUpdateForm.php | 2 +- core/lib/Thelia/Model/CustomerQuery.php | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Form/CustomerCreateForm.php b/core/lib/Thelia/Form/CustomerCreateForm.php index 2860b3b0c..38da394cc 100755 --- a/core/lib/Thelia/Form/CustomerCreateForm.php +++ b/core/lib/Thelia/Form/CustomerCreateForm.php @@ -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."); } diff --git a/core/lib/Thelia/Form/CustomerProfilUpdateForm.php b/core/lib/Thelia/Form/CustomerProfilUpdateForm.php index 255ceb382..55583d398 100755 --- a/core/lib/Thelia/Form/CustomerProfilUpdateForm.php +++ b/core/lib/Thelia/Form/CustomerProfilUpdateForm.php @@ -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."); diff --git a/core/lib/Thelia/Model/CustomerQuery.php b/core/lib/Thelia/Model/CustomerQuery.php index 8cf373af6..359d072bd 100755 --- a/core/lib/Thelia/Model/CustomerQuery.php +++ b/core/lib/Thelia/Model/CustomerQuery.php @@ -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