Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
findUser example
$logEntity
->
setActivity
(
$activity
)
;
$logEntity
->
setState
(
Progress::STATE_PROGRESS
)
;
$logEntity
->
setProfileId
(
$profile
->
getId
(
)
)
;
$logEntity
->
setProfileName
(
$profile
->
getTranslation
(
'label'
)
)
;
$logEntity
->
setFileId
(
$file
->
getId
(
)
)
;
$logEntity
->
setRecords
(
0
)
;
$logEntity
->
setConfig
(
$this
->
getConfig
(
$profile
,
$config
)
)
;
$contextSource
=
$context
->
getSource
(
)
;
$userId
=
$contextSource
instanceof AdminApiSource ?
$contextSource
->
getUserId
(
)
: null;
if
(
$userId
!== null
)
{
$logEntity
->
setUsername
(
$this
->
findUser
(
$context
,
$userId
)
->
getUsername
(
)
)
;
$logEntity
->
setUserId
(
$userId
)
;
}
$context
->
scope
(
Context::SYSTEM_SCOPE,
function
DContext
$context
)
use
(
$logEntity
)
: void
{
$logData
=
array_filter
(
$logEntity
->
jsonSerialize
(
)
,
fn
(
$value
)
=>
$value
!== null
)
;
$this
->logRepository->
create
(
[
$logData
]
,
$context
)
;
}
)
;
$logEntity
->
setProfile
(
$profile
)
;
$logEntity
->
setFile
(
$file
)
;