Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
isFastLogin example
public
function
validate
(
$password
, Constraint
$constraint
)
{
if
(
!
$constraint
instanceof Password
)
{
return
;
}
/** @var Form $form */
$form
=
$this
->context->
getRoot
(
)
;
if
(
$this
->
isFastLogin
(
$form
)
)
{
return
;
}
$minLength
=
(int)
$this
->config->
get
(
'minPassword'
)
;
if
(
empty
(
$password
)
||
(
$minLength
&& \
strlen
(
$password
)
<
$minLength
)
)
{
$this
->
addError
(
$this
->
getSnippet
(
self::SNIPPET_PASSWORD_LENGTH
)
)
;
}
if
(
$form
->
has
(
'passwordConfirmation'
)
&&
$form
->
get
(
'passwordConfirmation'
)
->
getData
(
)
!==
$password
)
{
$error
=
new
FormError
(
$this
->
getSnippet
(
self::SNIPPET_PASSWORD_CONFIRMATION
)
)
;
$customerId
=
$constraint
->
getCustomerId
(
)
;
if
(
empty
(
$email
)
)
{
$this
->
addError
(
$this
->
getSnippet
(
self::SNIPPET_MAIL_FAILURE
)
)
;
}
if
(
!
$this
->emailValidator->
isValid
(
$email
)
)
{
$this
->
addError
(
$this
->
getSnippet
(
self::SNIPPET_MAIL_FAILURE
)
)
;
}
if
(
!
$this
->
isFastLogin
(
$constraint
)
&&
$this
->
isExistingEmail
(
$email
,
$shop
,
$customerId
)
)
{
$this
->
addError
(
$this
->
getSnippet
(
self::SNIPPET_MAIL_DUPLICATE
)
)
;
}
}
/** * @param string $message */
private
function
addError
(
$message
)
{
$this
->context
->
buildViolation
(
$message
)