Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
resolveField example
$this
->
resolveSubJoin
(
$part
,
$definition
,
$query
,
$context
)
;
$query
->
addState
(
EntityDefinitionQueryHelper::HAS_TO_MANY_JOIN
)
;
continue
;
}
foreach
(
$part
->
getFields
(
)
as
$accessor
)
{
if
(
$accessor
=== '_score'
)
{
continue
;
}
$this
->
resolveField
(
$part
,
$accessor
,
$definition
,
$query
,
$context
)
;
}
}
}
private
function
resolveSubJoin
(
JoinGroup
$group
, EntityDefinition
$definition
, QueryBuilder
$query
, Context
$context
)
: void
{
$fields
= EntityDefinitionQueryHelper::
getFieldsOfAccessor
(
$definition
,
$group
->
getPath
(
)
, false
)
;
$first
=
array_shift
(
$fields
)
;
if
(
!
$first
instanceof AssociationField
)
{
return
isset
(
$partial
[
$field
->
getPropertyName
(
)
]
)
;
}
)
;
$parentAssociation
= null;
if
(
$definition
->
isInheritanceAware
(
)
&&
$context
->
considerInheritance
(
)
)
{
$parentAssociation
=
$definition
->
getFields
(
)
->
get
(
'parent'
)
;
if
(
$parentAssociation
!== null
)
{
$this
->queryHelper->
resolveField
(
$parentAssociation
,
$definition
,
$root
,
$query
,
$context
)
;
}
}
$addTranslation
= false;
/** @var Field $field */
foreach
(
$filtered
as
$field
)
{
// translated fields are handled after loop all together
if
(
$field
instanceof TranslatedField
)
{
$this
->queryHelper->
resolveField
(
$field
,
$definition
,
$root
,
$query
,
$context
)
;
/** * @param list<string> $paths */
public
function
build
(
QueryBuilder
$query
, EntityDefinition
$definition
, Criteria
$criteria
, Context
$context
, array
$paths
=
[
]
)
: QueryBuilder
{
$query
=
$this
->helper->
getBaseQuery
(
$query
,
$definition
,
$context
)
;
if
(
$definition
->
isInheritanceAware
(
)
&&
$context
->
considerInheritance
(
)
)
{
$parent
=
$definition
->
getFields
(
)
->
get
(
'parent'
)
;
if
(
$parent
)
{
$this
->helper->
resolveField
(
$parent
,
$definition
,
$definition
->
getEntityName
(
)
,
$query
,
$context
)
;
}
}
if
(
$criteria
->
getTerm
(
)
)
{
$pattern
=
$this
->interpreter->
interpret
(
(string)
$criteria
->
getTerm
(
)
)
;
$queries
=
$this
->scoreBuilder->
buildScoreQueries
(
$pattern
,
$definition
,
$definition
->
getEntityName
(
)
,
$context
)
;
$criteria
->
addQuery
(
...
$queries
)
;
}
$filters
=
$this
->
groupFilters
(
$definition
,
$criteria
,
$paths
)
;
array
{
if
(
empty
(
$ids
)
)
{
return
[
]
;
}
$query
=
new
QueryBuilder
(
$this
->connection
)
;
$query
->
from
(
EntityDefinitionQueryHelper::
escape
(
$root
->
getEntityName
(
)
)
,
EntityDefinitionQueryHelper::
escape
(
$root
->
getEntityName
(
)
)
)
;
$this
->queryHelper->
resolveField
(
$association
,
$root
,
$root
->
getEntityName
(
)
,
$query
,
$context
)
;
$alias
=
$root
->
getEntityName
(
)
. '.' .
$association
->
getPropertyName
(
)
;
if
(
$association
instanceof ManyToManyAssociationField
)
{
$alias
.= '.mapping';
}
$primaryKeys
=
$association
->
getReferenceDefinition
(
)
->
getPrimaryKeys
(
)
->
filter
(
function
DField
$field
)
{
if
(
$field
instanceof ReferenceVersionField ||
$field
instanceof VersionField
)
{
return
null;
}