Add new method getCustomerByEmail into CustomerQuery

This commit is contained in:
touffies
2013-10-23 20:28:41 +02:00
parent 10fee02fbf
commit 5c5861aa2e
3 changed files with 6 additions and 2 deletions

View File

@@ -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.");
}

View File

@@ -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.");

View File

@@ -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