public function load(QueryBuilder $query, ClassMetadata $metadata)
    {
        $field = $this->mapping['fieldname'];
        $target = $this->mapping['target'];
        $boltname = $metadata->getBoltName();

        if ($this->mapping['data']['has_sortorder']) {
            $order = "$field.sortorder";
            $query->addSelect($this->getPlatformGroupConcat("$field.sortorder", $order, '_' . $field . '_sortorder',
                $query));
        } else {
            $order = "$field.id";
        }

        $from = $query->getQueryPart('from');

        if (isset($from[0]['alias'])) {
            $alias = $from[0]['alias'];
        } else {
            $alias = $from[0]['table'];
        }

        $quotedField = $query->getConnection()->quoteIdentifier($field);

        $query
            ->addSelect($this->getPlatformGroupConcat("$field.id", $order, '_' . $field . '_id', $query))
            ->addSelect($this->getPlatformGroupConcat("$field.slug", $order, '_' . $field . '_slug', $query))
            ->addSelect($this->getPlatformGroupConcat("$field.name", $order, '_' . $field . '_name', $query))
            ->addSelect($this->getPlatformGroupConcat("$field.taxonomytype", $order, '_' . $field . '_taxonomytype',
                $query))
            ->leftJoin($alias, $target, $quotedField,
                "$alias.id = $quotedField.content_id AND $quotedField.contenttype='$boltname' AND $quotedField.taxonomytype='$field'")
            ->addGroupBy("$alias.id")
        ;

        return null;
    }
public function load(QueryBuilder $query, ClassMetadata $metadata)
    {
        $field = $this->mapping['fieldname'];
        $target = $this->mapping['target'];
        $boltname = $metadata->getBoltName();

        if ($this->mapping['data']['has_sortorder']) {
            $order = "$field.sortorder";
            $query->addSelect($this->getPlatformGroupConcat("$field.sortorder", $order, '_' . $field . '_sortorder',
                $query));
        } else {
            $order = "$field.id";
        }

        $from = $query->getQueryPart('from');

        if (isset($from[0]['alias'])) {
            $alias = $from[0]['alias'];
        } else {
            $alias = $from[0]['table'];
        }

        $quotedField = $query->getConnection()->quoteIdentifier($field);

        $query
            ->addSelect($this->getPlatformGroupConcat("$field.id", $order, '_' . $field . '_id', $query))
            ->addSelect($this->getPlatformGroupConcat("$field.slug", $order, '_' . $field . '_slug', $query))
            ->addSelect($this->getPlatformGroupConcat("$field.name", $order, '_' . $field . '_name', $query))
            ->addSelect($this->getPlatformGroupConcat("$field.taxonomytype", $order, '_' . $field . '_taxonomytype',
                $query))
            ->leftJoin($alias, $target, $quotedField,
                "$alias.id = $quotedField.content_id AND $quotedField.contenttype='$boltname' AND $quotedField.taxonomytype='$field'")
            ->addGroupBy("$alias.id")
        ;

        return null;
    }
public function load ( QueryBuilder $ query , ClassMetadata $ metadata ) { $ field = $ this -> mapping [ 'fieldname' ] ; $ target = $ this -> mapping [ 'target' ] ; $ boltname = $ metadata -> getBoltName ( ) ; if ( $ this -> mapping [ 'data' ] [ 'has_sortorder' ] ) { $ order = "$field.sortorder" ; $ query -> addSelect ( $ this -> getPlatformGroupConcat ( "$field.sortorder" , $ order , '_' . $ field . '_sortorder' , $ query ) ) ; } else { $ order = "$field.id" ; } $ from = $ query -> getQueryPart ( 'from' ) ; if ( isset ( $ from [ 0 ] [ 'alias' ] ) ) { $ alias = $ from [ 0 ] [ 'alias' ] ; } else { $ alias = $ from [ 0 ] [ 'table' ] ; } $ quotedField = $ query -> getConnection ( ) -> quoteIdentifier ( $ field ) ; $ query -> addSelect ( $ this -> getPlatformGroupConcat ( "$field.id" , $ order , '_' . $ field . '_id' , $ query ) ) -> addSelect ( $ this -> getPlatformGroupConcat ( "$field.slug" , $ order , '_' . $ field . '_slug' , $ query ) ) -> addSelect ( $ this -> getPlatformGroupConcat ( "$field.name" , $ order , '_' . $ field . '_name' , $ query ) ) -> addSelect ( $ this -> getPlatformGroupConcat ( "$field.taxonomytype" , $ order , '_' . $ field . '_taxonomytype' , $ query ) ) -> leftJoin ( $ alias , $ target , $ quotedField , "$alias.id = $quotedField.content_id AND $quotedField.contenttype='$boltname' AND $quotedField.taxonomytype='$field'" ) -> addGroupBy ( "$alias.id" ) ; return null ; }
For the taxonomy field the load event modifies the query to fetch taxonomies related
to a content record from the join table.

It does this via an additional ->addSelect() and ->leftJoin() call on the QueryBuilder
which includes then includes the taxonomies in the same query as the content fetch.

@param QueryBuilder  $query
@param ClassMetadata $metadata

@return QueryBuilder|null
For the taxonomy field the load event modifies the query to fetch taxonomies related to a content record from the join table .