Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
deleteRecoveryForUser example
if
(
!
$user
)
{
return
;
}
$userId
=
$user
->
getId
(
)
;
$userIdCriteria
=
new
Criteria
(
)
;
$userIdCriteria
->
addFilter
(
new
EqualsFilter
(
'userId',
$userId
)
)
;
$userIdCriteria
->
addAssociation
(
'user'
)
;
if
(
$existingRecovery
=
$this
->
getUserRecovery
(
$userIdCriteria
,
$context
)
)
{
$this
->
deleteRecoveryForUser
(
$existingRecovery
,
$context
)
;
}
$recoveryData
=
[
'userId' =>
$userId
,
'hash' => Random::
getAlphanumericString
(
32
)
,
]
;
$this
->userRecoveryRepo->
create
(
[
$recoveryData
]
,
$context
)
;
$recovery
=
$this
->
getUserRecovery
(
$userIdCriteria
,
$context
)
;