Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setAdmin example
$mediaCollection
=
new
MediaCollection
(
)
;
$userId
= 'f343a3c119cf42a7841aa0ac5094908c';
$user
=
new
UserEntity
(
)
;
$user
->
setId
(
$userId
)
;
$user
->
setFirstName
(
'Manufacturer'
)
;
$user
->
setLastName
(
''
)
;
$user
->
setPassword
(
'password'
)
;
$user
->
setUsername
(
'user1'
)
;
$user
->
setActive
(
true
)
;
$user
->
setAdmin
(
true
)
;
$user
->
setEmail
(
'user1@shop.de'
)
;
$user
->
setCreatedAt
(
new
\
DateTime
(
'2018-01-15T08:01:16.000+00:00'
)
)
;
$user
->
internalSetEntityData
(
'user',
new
FieldVisibility
(
[
]
)
)
;
$media
=
new
MediaEntity
(
)
;
$media
->
setId
(
'3e352be2d85846dd97529c0f6b544870'
)
;
$media
->
setUser
(
clone
$user
)
;
$media
->
setUserId
(
$userId
)
;
$media
->
setMimeType
(
'image/jpg'
)
;
$media
->
setFileExtension
(
'jpg'
)
;
$media
->
setFileSize
(
18921
)
;
public
function
getInput
(
)
: EntityCollection|Entity
{
$userId
= '6f51622eb3814c75ae0263cece27ce72';
$user
=
new
UserEntity
(
)
;
$user
->
setId
(
$userId
)
;
$user
->
setFirstName
(
'Manufacturer'
)
;
$user
->
setLastName
(
''
)
;
$user
->
setPassword
(
'password'
)
;
$user
->
setUsername
(
'user1'
)
;
$user
->
setActive
(
true
)
;
$user
->
setAdmin
(
true
)
;
$user
->
setEmail
(
'user1@shop.de'
)
;
$user
->
setCreatedAt
(
new
\
DateTime
(
'2018-01-15T08:01:16.000+00:00'
)
)
;
$user
->
internalSetEntityData
(
'user',
new
FieldVisibility
(
[
]
)
)
;
$media
=
new
MediaEntity
(
)
;
$media
->
setId
(
'548faa1f7846436c85944f4aea792d96'
)
;
$media
->
setUserId
(
$userId
)
;
$media
->
setMimeType
(
'image/jpg'
)
;
$media
->
setFileExtension
(
'jpg'
)
;
$media
->
setFileSize
(
93889
)
;
$media
->
setTitle
(
'2'
)
;
$mediaCollection
=
new
MediaCollection
(
)
;
$userId
= '6f51622eb3814c75ae0263cece27ce72';
$user
=
new
UserEntity
(
)
;
$user
->
setId
(
$userId
)
;
$user
->
setFirstName
(
'Manufacturer'
)
;
$user
->
setLastName
(
''
)
;
$user
->
setPassword
(
'password'
)
;
$user
->
setUsername
(
'user1'
)
;
$user
->
setActive
(
true
)
;
$user
->
setAdmin
(
true
)
;
$user
->
setEmail
(
'user1@shop.de'
)
;
$user
->
setCreatedAt
(
new
\
DateTime
(
'2018-01-15T08:01:16.000+00:00'
)
)
;
$user
->
internalSetEntityData
(
'user',
new
FieldVisibility
(
[
]
)
)
;
$media1
=
new
MediaEntity
(
)
;
$media1
->
setId
(
'3e352be2d85846dd97529c0f6b544870'
)
;
$media1
->
setUser
(
$user
)
;
$media1
->
setUserId
(
$userId
)
;
$media1
->
setMimeType
(
'image/jpg'
)
;
$media1
->
setFileExtension
(
'jpg'
)
;
$media1
->
setFileSize
(
18921
)
;
$repository
=
$this
->modelManager->
getRepository
(
Rule::
class
)
;
$adminRole
=
$repository
->
findOneBy
(
[
'roleId' =>
$role
->
getId
(
)
,
'resourceId' => null,
'privilegeId' => null,
]
)
;
$resourceAdmins
=
$this
->
getResourceAdminRules
(
$role
->
getId
(
)
)
;
// The admin property is temporary used to flag the passed role as admin role
if
(
$adminRole
instanceof Rule &&
$adminRole
->
getRoleId
(
)
)
{
$role
->
setAdmin
(
1
)
;
}
else
{
$role
->
setAdmin
(
0
)
;
}
}
foreach
(
$resources
as
$resource
)
{
$data
[
]
=
$this
->
getResourceNode
(
$resource
,
$role
,
$resourceAdmins
)
;
}
$this
->
View
(
)
->
assign
(
[
'success' => true,
public
function
getInput
(
)
: EntityCollection|Entity
{
$userId
= '6f51622eb3814c75ae0263cece27ce72';
$user
=
new
UserEntity
(
)
;
$user
->
setId
(
$userId
)
;
$user
->
setFirstName
(
'Manufacturer'
)
;
$user
->
setLastName
(
''
)
;
$user
->
setPassword
(
'password'
)
;
$user
->
setUsername
(
'user1'
)
;
$user
->
setActive
(
true
)
;
$user
->
setAdmin
(
true
)
;
$user
->
setEmail
(
'user1@shop.de'
)
;
$user
->
setCreatedAt
(
new
\
DateTime
(
'2018-01-15T08:01:16.000+00:00'
)
)
;
$user
->
internalSetEntityData
(
'user',
new
FieldVisibility
(
[
]
)
)
;
$media
=
new
MediaEntity
(
)
;
$media
->
setId
(
'548faa1f7846436c85944f4aea792d96'
)
;
$media
->
setUserId
(
$userId
)
;
$media
->
setMimeType
(
'image/jpg'
)
;
$media
->
setFileExtension
(
'jpg'
)
;
$media
->
setFileSize
(
93889
)
;
$media
->
setTitle
(
'2'
)
;