protected function rewriteQueryFilterParameters(Filter $filter, SelectQuery $query, $field)
    {
        $boltName = $query->getContentType();

        $newExpression = $this->em->createExpressionBuilder();
        $count = 0;
        foreach ($query->getWhereParametersFor($field) as $paramKey => $paramValue) {
            $parameterParts = explode('_', $paramKey);
            array_pop($parameterParts);
            array_shift($parameterParts);
            $subkey = join('_', $parameterParts);

            $parser = new QueryParameterParser($newExpression);
            $parsed = $parser->parseValue($paramValue);
            $placeholder = $paramKey;
            $q = $this->em->createQueryBuilder();
            $q->addSelect('content_id')
                ->from($this->mapping['tables']['field_value'], 'f')
                ->andWhere("f.content_id = _$boltName.id")
                ->andWhere("f.contenttype = '$boltName'")
                ->andWhere("f.name = '$field'")
                ->andWhere("f.fieldname = '" . $subkey . "'")
                ->andWhere(
                    $q->expr()
                        ->orX()
                        ->add(
                            $q->expr()->{$parsed['operator']}('f.value_text', ':' . $placeholder)
                        )
                        ->add(
                            $q->expr()->{$parsed['operator']}('f.value_string', ':' . $placeholder)
                        )
                        ->add(
                            $q->expr()->{$parsed['operator']}('f.value_json_array', ':' . $placeholder)
                        )
                );
            $filter->setParameter($placeholder, $parsed['value']);
            $count++;
        }
        $comp = $newExpression->andX($newExpression->in('_' . $boltName . '.id', $q->getSQL()));
        $filter->setKey('_' . $boltName . '.id');
        $filter->setExpression($comp);
    }
protected function rewriteQueryFilterParameters(Filter $filter, SelectQuery $query, $field)
    {
        $boltName = $query->getContentType();

        $newExpression = $this->em->createExpressionBuilder();
        $count = 0;
        foreach ($query->getWhereParametersFor($field) as $paramKey => $paramValue) {
            $parameterParts = explode('_', $paramKey);
            array_pop($parameterParts);
            array_shift($parameterParts);
            $subkey = join('_', $parameterParts);

            $parser = new QueryParameterParser($newExpression);
            $parsed = $parser->parseValue($paramValue);
            $placeholder = $paramKey;
            $q = $this->em->createQueryBuilder();
            $q->addSelect('content_id')
                ->from($this->mapping['tables']['field_value'], 'f')
                ->andWhere("f.content_id = _$boltName.id")
                ->andWhere("f.contenttype = '$boltName'")
                ->andWhere("f.name = '$field'")
                ->andWhere("f.fieldname = '" . $subkey . "'")
                ->andWhere(
                    $q->expr()
                        ->orX()
                        ->add(
                            $q->expr()->{$parsed['operator']}('f.value_text', ':' . $placeholder)
                        )
                        ->add(
                            $q->expr()->{$parsed['operator']}('f.value_string', ':' . $placeholder)
                        )
                        ->add(
                            $q->expr()->{$parsed['operator']}('f.value_json_array', ':' . $placeholder)
                        )
                );
            $filter->setParameter($placeholder, $parsed['value']);
            $count++;
        }
        $comp = $newExpression->andX($newExpression->in('_' . $boltName . '.id', $q->getSQL()));
        $filter->setKey('_' . $boltName . '.id');
        $filter->setExpression($comp);
    }
protected function rewriteQueryFilterParameters ( Filter $ filter , SelectQuery $ query , $ field ) { $ boltName = $ query -> getContentType ( ) ; $ newExpression = $ this -> em -> createExpressionBuilder ( ) ; $ count = 0 ; foreach ( $ query -> getWhereParametersFor ( $ field ) as $ paramKey => $ paramValue ) { $ parameterParts = explode ( '_' , $ paramKey ) ; array_pop ( $ parameterParts ) ; array_shift ( $ parameterParts ) ; $ subkey = join ( '_' , $ parameterParts ) ; $ parser = new QueryParameterParser ( $ newExpression ) ; $ parsed = $ parser -> parseValue ( $ paramValue ) ; $ placeholder = $ paramKey ; $ q = $ this -> em -> createQueryBuilder ( ) ; $ q -> addSelect ( 'content_id' ) -> from ( $ this -> mapping [ 'tables' ] [ 'field_value' ] , 'f' ) -> andWhere ( "f.content_id = _$boltName.id" ) -> andWhere ( "f.contenttype = '$boltName'" ) -> andWhere ( "f.name = '$field'" ) -> andWhere ( "f.fieldname = '" . $ subkey . "'" ) -> andWhere ( $ q -> expr ( ) -> orX ( ) -> add ( $ q -> expr ( ) -> { $ parsed [ 'operator' ] } ( 'f.value_text' , ':' . $ placeholder ) ) -> add ( $ q -> expr ( ) -> { $ parsed [ 'operator' ] } ( 'f.value_string' , ':' . $ placeholder ) ) -> add ( $ q -> expr ( ) -> { $ parsed [ 'operator' ] } ( 'f.value_json_array' , ':' . $ placeholder ) ) ) ; $ filter -> setParameter ( $ placeholder , $ parsed [ 'value' ] ) ; $ count ++ ; } $ comp = $ newExpression -> andX ( $ newExpression -> in ( '_' . $ boltName . '.id' , $ q -> getSQL ( ) ) ) ; $ filter -> setKey ( '_' . $ boltName . '.id' ) ; $ filter -> setExpression ( $ comp ) ; }
This method does an in-place modification of a generic ContentType.field
query to the format actually used in the raw SQL. For instance a simple
query might say `entries.repeater = 'title=%Test%'` but now we are in
the context of entries the actual SQL fragment needs to do a sub-select
on the bolt_field_value table and only return the content_ids where this
query matches so this method rewrites the SQL fragment just before the
query gets sent.

@param Filter      $filter
@param SelectQuery $query
@param string      $field
This method does an in - place modification of a generic ContentType . field query to the format actually used in the raw SQL . For instance a simple query might say entries . repeater = title = %Test% but now we are in the context of entries the actual SQL fragment needs to do a sub - select on the bolt_field_value table and only return the content_ids where this query matches so this method rewrites the SQL fragment just before the query gets sent .