Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getAssociationForEntity example
$joinEntities
=
$this
->
filterJoinEntities
(
$joinEntities
)
;
$builder
=
$this
->
getDqlHelper
(
)
->
getEntityManager
(
)
->
createQueryBuilder
(
)
->
select
(
'partial detail.{id}'
)
->
from
(
Detail::
class
, 'detail'
)
// only products with attributes are considered to be valid ->
innerJoin
(
'detail.attribute', 'attr'
)
->
leftJoin
(
'detail.article', 'article'
)
;
foreach
(
$joinEntities
as
$entity
)
{
$join
=
$this
->
getDqlHelper
(
)
->
getAssociationForEntity
(
$entity
)
;
if
(
!\
is_string
(
$join
)
)
{
continue
;
}
$builder
->
leftJoin
(
$join
,
$this
->
getDqlHelper
(
)
->
getPrefixForEntity
(
$entity
)
)
;
}
list
(
$dql
,
$params
)
=
$this
->
getDqlHelper
(
)
->
getDqlFromTokens
(
$tokens
)
;
foreach
(
$params
as
$key
=>
$value
)
{
$builder
->
setParameter
(
$key
,
$value
)
;
}