Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setIpAddress example
$this
->front->
Plugins
(
)
->
Json
(
)
->
setRenderer
(
true
)
;
try
{
$params
=
$request
->request->
all
(
)
;
$params
[
'key'
]
=
html_entity_decode
(
$params
[
'key'
]
)
;
$ip
=
$this
->ipAnonymizer->
anonymize
(
$request
->
getClientIp
(
)
)
;
$logModel
=
new
Log
(
)
;
$logModel
->
fromArray
(
$params
)
;
$logModel
->
setDate
(
new
DateTime
(
'now'
)
)
;
$logModel
->
setIpAddress
(
$ip
)
;
$logModel
->
setUserAgent
(
$request
->server->
get
(
'HTTP_USER_AGENT', 'Unknown'
)
)
;
$this
->em->
persist
(
$logModel
)
;
$this
->em->
flush
(
)
;
$data
=
$this
->em->
toArray
(
$logModel
)
;
$this
->
View
(
)
->
assign
(
[
'success' => true, 'data' =>
$data
]
)
;
}
catch
(
Exception
$e
)
{
$this
->
View
(
)
->
assign
(
[
'success' => false, 'errorMsg' =>
$e
->
getMessage
(
)
]
)
;
}
}