Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getRolesQuery example
if
(
$id
!== null
)
{
$queryBuilder
=
$this
->
getUserRepository
(
)
->
getRolesQueryBuilder
(
)
;
$query
=
$queryBuilder
->
setFirstResult
(
0
)
->
setMaxResults
(
1
)
->
andWhere
(
'roles.id = :role_id'
)
->
setParameter
(
':role_id',
(int)
$id
)
->
getQuery
(
)
;
$count
= 1;
}
else
{
$query
=
$this
->
getUserRepository
(
)
->
getRolesQuery
(
$offset
,
$limit
)
;
$count
=
$this
->
get
(
'models'
)
->
getQueryCount
(
$query
)
;
}
$roles
=
$query
->
getArrayResult
(
)
;
// Strip roles with parent id set
foreach
(
$roles
as
&
$role
)
{
if
(
!
empty
(
$role
[
'parentID'
]
)
)
{
unset
(
$role
)
;
}
}