Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setHash example
$sErrorFlag
[
'eMail'
]
= true;
}
}
if
(
empty
(
$sErrorFlag
)
)
{
if
(
!
empty
(
Shopware
(
)
->
Config
(
)
->sOPTINVOTE
)
&&
empty
(
Shopware
(
)
->
Session
(
)
->
get
(
'sUserId'
)
)
)
{
$hash
= Random::
getAlphanumericString
(
32
)
;
// Save comment confirm for the optin
$blogCommentModel
=
new
CommentConfirm
(
)
;
$blogCommentModel
->
setCreationDate
(
new
DateTime
(
'now'
)
)
;
$blogCommentModel
->
setHash
(
$hash
)
;
$blogCommentModel
->
setData
(
serialize
(
$this
->
Request
(
)
->
getPost
(
)
)
)
;
$this
->
get
(
'models'
)
->
persist
(
$blogCommentModel
)
;
$this
->
get
(
'models'
)
->
flush
(
)
;
$link
=
$this
->
Front
(
)
->
ensureRouter
(
)
->
assemble
(
[
'sViewport' => 'blog', 'action' => 'rating', 'blogArticle' =>
$blogArticleId
, 'sConfirmation' =>
$hash
]
)
;
$context
=
[
'sConfirmLink' =>
$link
, 'sArticle' =>
[
'title' =>
$blogArticleData
[
'title'
]
]
]
;
$mail
=
Shopware
(
)
->
TemplateMail
(
)
->
createMail
(
'sOPTINBLOGCOMMENT',
$context
)
;
$mail
->
addTo
(
$this
->
Request
(
)
->
getParam
(
'eMail'
)
)
;
$mail
->
send
(
)
;
}
static
::
expectExceptionMessage
(
'No sales channel found.'
)
;
$userEmail
= 'existing@example.com';
$context
=
new
Context
(
new
SystemSource
(
)
,
[
]
, Defaults::CURRENCY,
[
Defaults::LANGUAGE_SYSTEM
]
)
;
$user
=
new
UserEntity
(
)
;
$user
->
setUniqueIdentifier
(
Uuid::
randomHex
(
)
)
;
$user
->
setId
(
Uuid::
randomHex
(
)
)
;
$recoveryEntity
=
new
UserRecoveryEntity
(
)
;
$recoveryEntity
->
setUniqueIdentifier
(
Uuid::
randomHex
(
)
)
;
$recoveryEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$recoveryEntity
->
setHash
(
Uuid::
randomHex
(
)
)
;
/** @var StaticEntityRepository<UserCollection> $userRepository */
$userRepository
=
new
StaticEntityRepository
(
[
new
UserCollection
(
[
$user
]
)
,
]
,
new
UserDefinition
(
)
)
;
/** @var StaticEntityRepository<UserRecoveryCollection> $recoveryRepository */
$recoveryRepository
=
new
StaticEntityRepository
(
[
new
UserRecoveryCollection
(
[
$recoveryEntity
]
)
,
new
UserRecoveryCollection
(
[
$recoveryEntity
]
)
,
]
,
new
UserRecoveryDefinition
(
)
)
;
$criteria
->
addAssociation
(
'defaultShippingAddress.country'
)
;
$criteria
->
addAssociation
(
'defaultShippingAddress.countryState'
)
;
$criteria
->
addAssociation
(
'defaultShippingAddress.salutation'
)
;
/** @var CustomerEntity $customerEntity */
$customerEntity
=
$this
->customerRepository->
search
(
$criteria
,
$context
->
getContext
(
)
)
->
first
(
)
;
if
(
$customerEntity
->
getDoubleOptInRegistration
(
)
)
{
$this
->eventDispatcher->
dispatch
(
$this
->
getDoubleOptInEvent
(
$customerEntity
,
$context
,
$data
->
get
(
'storefrontUrl'
)
,
$data
->
get
(
'redirectTo'
)
)
)
;
// We don't want to leak the hash in store-api
$customerEntity
->
setHash
(
''
)
;
return
new
CustomerResponse
(
$customerEntity
)
;
}
$response
=
new
CustomerResponse
(
$customerEntity
)
;
$newToken
=
$this
->contextPersister->
replace
(
$context
->
getToken
(
)
,
$context
)
;
$this
->contextPersister->
save
(
$newToken
,
[
static
::
expectException
(
CustomerAlreadyConfirmedException::
class
)
;
$this
->route->
confirm
(
$this
->
mockRequestDataBag
(
)
,
$this
->context
)
;
}
protected
function
mockCustomer
(
)
: CustomerEntity
{
$customer
=
new
CustomerEntity
(
)
;
$customer
->
setId
(
'customer-1'
)
;
$customer
->
setActive
(
Feature::
isActive
(
'v6.6.0.0'
)
)
;
$customer
->
setEmail
(
'test@test.test'
)
;
$customer
->
setHash
(
'hash'
)
;
$customer
->
setGuest
(
false
)
;
$customer
->
setDoubleOptInRegistration
(
true
)
;
$customer
->
setDoubleOptInEmailSentDate
(
new
\
DateTime
(
)
)
;
return
$customer
;
}
protected
function
mockRequestDataBag
(
)
: RequestDataBag
{
return
new
RequestDataBag
(
[
'hash' => 'hash',
public
function
load
(
Request
$request
, SalesChannelContext
$context
, string
$hash
)
: AccountRecoverPasswordPage
{
$page
=
$this
->genericLoader->
load
(
$request
,
$context
)
;
$page
= AccountRecoverPasswordPage::
createFrom
(
$page
)
;
$page
->
setHash
(
$hash
)
;
$customerHashCriteria
=
new
Criteria
(
)
;
$customerHashCriteria
->
addFilter
(
new
EqualsFilter
(
'hash',
$hash
)
)
;
$customerRecoveryResponse
=
$this
->recoveryIsExpiredRoute
->
load
(
new
RequestDataBag
(
[
'hash' =>
$hash
]
)
,
$context
)
;
$page
->
setHashExpired
(
$customerRecoveryResponse
->
isExpired
(
)
)
;
$this
->eventDispatcher->
dispatch
(
new
AccountRecoverPasswordPageLoadedEvent
(
$page
,
$context
,
$request
)
)
;
protected
function
saveBackup
(
$path
,
$filterString
,
$operations
,
$items
)
{
$backup
=
new
BackupModel
(
)
;
$backup
->
setFilterString
(
$filterString
)
;
$backup
->
setOperationString
(
$this
->
operationsToString
(
$operations
)
)
;
$backup
->
setItems
(
$items
)
;
$backup
->
setPath
(
$path
)
;
$backup
->
setHash
(
sha1_file
(
$path
)
)
;
$backup
->
setSize
(
(int)
filesize
(
$path
)
)
;
$backup
->
setDate
(
new
DateTime
(
)
)
;
$this
->
getDqlHelper
(
)
->
getEntityManager
(
)
->
persist
(
$backup
)
;
$this
->
getDqlHelper
(
)
->
getEntityManager
(
)
->
flush
(
$backup
)
;
}
/** * Dumps a given table to disc - as only needed columns are exported, this is quite fast * * @param string $table * @param string $name * @param int[] $ids * @param bool $newBackup * * @throws RuntimeException */