Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
CommentConfirm example
$validator
=
$this
->container->
get
(
EmailValidator::
class
)
;
if
(
!
empty
(
Shopware
(
)
->
Config
(
)
->sOPTINVOTE
)
&&
(
empty
(
$this
->
Request
(
)
->eMail
)
|| !
$validator
->
isValid
(
$this
->
Request
(
)
->eMail
)
)
)
{
$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
)
;