protected function _appendFields($query, $surrogate, $options)
    {
        if ($query->getEagerLoader()->isAutoFieldsEnabled() === false) {
            return;
        }

        $fields = $surrogate->clause('select') ?: $options['fields'];
        $target = $this->_targetTable;
        $autoFields = $surrogate->isAutoFieldsEnabled();

        if (empty($fields) && !$autoFields) {
            if ($options['includeFields'] && ($fields === null || $fields !== false)) {
                $fields = $target->getSchema()->columns();
            }
        }

        if ($autoFields === true) {
            $fields = array_filter((array)$fields);
            $fields = array_merge($fields, $target->getSchema()->columns());
        }

        if ($fields) {
            $query->select($query->aliasFields($fields, $this->_name));
        }
        $query->addDefaultTypes($target);
    }
protected function _appendFields($query, $surrogate, $options)
    {
        if ($query->getEagerLoader()->isAutoFieldsEnabled() === false) {
            return;
        }

        $fields = $surrogate->clause('select') ?: $options['fields'];
        $target = $this->_targetTable;
        $autoFields = $surrogate->isAutoFieldsEnabled();

        if (empty($fields) && !$autoFields) {
            if ($options['includeFields'] && ($fields === null || $fields !== false)) {
                $fields = $target->getSchema()->columns();
            }
        }

        if ($autoFields === true) {
            $fields = array_filter((array)$fields);
            $fields = array_merge($fields, $target->getSchema()->columns());
        }

        if ($fields) {
            $query->select($query->aliasFields($fields, $this->_name));
        }
        $query->addDefaultTypes($target);
    }
protected function _appendFields ( $ query , $ surrogate , $ options ) { if ( $ query -> getEagerLoader ( ) -> isAutoFieldsEnabled ( ) === false ) { return ; } $ fields = $ surrogate -> clause ( 'select' ) ? : $ options [ 'fields' ] ; $ target = $ this -> _targetTable ; $ autoFields = $ surrogate -> isAutoFieldsEnabled ( ) ; if ( empty ( $ fields ) && ! $ autoFields ) { if ( $ options [ 'includeFields' ] && ( $ fields === null || $ fields !== false ) ) { $ fields = $ target -> getSchema ( ) -> columns ( ) ; } } if ( $ autoFields === true ) { $ fields = array_filter ( ( array ) $ fields ) ; $ fields = array_merge ( $ fields , $ target -> getSchema ( ) -> columns ( ) ) ; } if ( $ fields ) { $ query -> select ( $ query -> aliasFields ( $ fields , $ this -> _name ) ) ; } $ query -> addDefaultTypes ( $ target ) ; }
Helper function used to conditionally append fields to the select clause of
a query from the fields found in another query object.

@param \Cake\ORM\Query $query the query that will get the fields appended to
@param \Cake\ORM\Query $surrogate the query having the fields to be copied from
@param array $options options passed to the method `attachTo`
@return void
Helper function used to conditionally append fields to the select clause of a query from the fields found in another query object .