src/Sulu/Component/Rest/Listing/ListQueryBuilder.php
private function performSelectFromField($field, $prefix = 'u')
    {
        // Relation name and field delimited by underscore
        $fieldParts = explode('_', $field);

        // temporary variable for saving field name (needed for array results like [0])
        $realFieldName = $field;
        // check if a certain field number is searched
        if (preg_match('/^(.*)\[(\d+)\]$/', $fieldParts[0], $regresult)) {
            $fieldParts[0] = $regresult[1];
            $realFieldName = implode('_', $fieldParts);
            $this->relationalFilters[$realFieldName] = $regresult[2];
        }

        // If field is delimited and is a Relation
        if (count($fieldParts) >= 2 && $this->isRelation($fieldParts[0])) {
            $this->joins .= $this->generateJoins($fieldParts, $prefix);
            if (in_array($field, $this->fields)) {
                // last element is column name and next-to-last is the associationPrefix
                $i = count($fieldParts) - 1;

                // {associationPrefix}.{columnName} {alias}
                $parent = $fieldParts[$i - 1];
                $tempField = $fieldParts[$i];
                $alias = $realFieldName;

                $this->addToSelect($parent, $tempField, $alias);
            }
        } elseif (in_array($field, $this->fields) && in_array($field, $this->fieldNames)) {
            $this->addToSelect($prefix, $field);
        }
    }
private function performSelectFromField($field, $prefix = 'u')
    {
        // Relation name and field delimited by underscore
        $fieldParts = explode('_', $field);

        // temporary variable for saving field name (needed for array results like [0])
        $realFieldName = $field;
        // check if a certain field number is searched
        if (preg_match('/^(.*)\[(\d+)\]$/', $fieldParts[0], $regresult)) {
            $fieldParts[0] = $regresult[1];
            $realFieldName = implode('_', $fieldParts);
            $this->relationalFilters[$realFieldName] = $regresult[2];
        }

        // If field is delimited and is a Relation
        if (count($fieldParts) >= 2 && $this->isRelation($fieldParts[0])) {
            $this->joins .= $this->generateJoins($fieldParts, $prefix);
            if (in_array($field, $this->fields)) {
                // last element is column name and next-to-last is the associationPrefix
                $i = count($fieldParts) - 1;

                // {associationPrefix}.{columnName} {alias}
                $parent = $fieldParts[$i - 1];
                $tempField = $fieldParts[$i];
                $alias = $realFieldName;

                $this->addToSelect($parent, $tempField, $alias);
            }
        } elseif (in_array($field, $this->fields) && in_array($field, $this->fieldNames)) {
            $this->addToSelect($prefix, $field);
        }
    }
private function performSelectFromField ( $ field , $ prefix = 'u' ) { // Relation name and field delimited by underscore $ fieldParts = explode ( '_' , $ field ) ; // temporary variable for saving field name (needed for array results like [0]) $ realFieldName = $ field ; // check if a certain field number is searched if ( preg_match ( '/^(.*)\[(\d+)\]$/' , $ fieldParts [ 0 ] , $ regresult ) ) { $ fieldParts [ 0 ] = $ regresult [ 1 ] ; $ realFieldName = implode ( '_' , $ fieldParts ) ; $ this -> relationalFilters [ $ realFieldName ] = $ regresult [ 2 ] ; } // If field is delimited and is a Relation if ( count ( $ fieldParts ) >= 2 && $ this -> isRelation ( $ fieldParts [ 0 ] ) ) { $ this -> joins .= $ this -> generateJoins ( $ fieldParts , $ prefix ) ; if ( in_array ( $ field , $ this -> fields ) ) { // last element is column name and next-to-last is the associationPrefix $ i = count ( $ fieldParts ) - 1 ; // {associationPrefix}.{columnName} {alias} $ parent = $ fieldParts [ $ i - 1 ] ; $ tempField = $ fieldParts [ $ i ] ; $ alias = $ realFieldName ; $ this -> addToSelect ( $ parent , $ tempField , $ alias ) ; } } elseif ( in_array ( $ field , $ this -> fields ) && in_array ( $ field , $ this -> fieldNames ) ) { $ this -> addToSelect ( $ prefix , $ field ) ; } }
solves the relations for a single field and generate dql for select and joins.

@param string $field
@param string $prefix
solves the relations for a single field and generate dql for select and joins .