protected function _iterateClause(Query $query, $name = '', $config = [])
    {
        $clause = $query->clause($name);
        if (!$clause || !$clause->count()) {
            return false;
        }

        $alias = $config['hasOneAlias'];
        $fields = $this->_translationFields();
        $mainTableAlias = $config['mainTableAlias'];
        $mainTableFields = $this->_mainFields();
        $joinRequired = false;

        $clause->iterateParts(function ($c, &$field) use ($fields, $alias, $mainTableAlias, $mainTableFields, &$joinRequired) {
            if (!is_string($field) || strpos($field, '.')) {
                return $c;
            }

            if (in_array($field, $fields)) {
                $joinRequired = true;
                $field = "$alias.$field";
            } elseif (in_array($field, $mainTableFields)) {
                $field = "$mainTableAlias.$field";
            }

            return $c;
        });

        return $joinRequired;
    }
protected function _iterateClause(Query $query, $name = '', $config = [])
    {
        $clause = $query->clause($name);
        if (!$clause || !$clause->count()) {
            return false;
        }

        $alias = $config['hasOneAlias'];
        $fields = $this->_translationFields();
        $mainTableAlias = $config['mainTableAlias'];
        $mainTableFields = $this->_mainFields();
        $joinRequired = false;

        $clause->iterateParts(function ($c, &$field) use ($fields, $alias, $mainTableAlias, $mainTableFields, &$joinRequired) {
            if (!is_string($field) || strpos($field, '.')) {
                return $c;
            }

            if (in_array($field, $fields)) {
                $joinRequired = true;
                $field = "$alias.$field";
            } elseif (in_array($field, $mainTableFields)) {
                $field = "$mainTableAlias.$field";
            }

            return $c;
        });

        return $joinRequired;
    }
protected function _iterateClause ( Query $ query , $ name = '' , $ config = [ ] ) { $ clause = $ query -> clause ( $ name ) ; if ( ! $ clause || ! $ clause -> count ( ) ) { return false ; } $ alias = $ config [ 'hasOneAlias' ] ; $ fields = $ this -> _translationFields ( ) ; $ mainTableAlias = $ config [ 'mainTableAlias' ] ; $ mainTableFields = $ this -> _mainFields ( ) ; $ joinRequired = false ; $ clause -> iterateParts ( function ( $ c , & $ field ) use ( $ fields , $ alias , $ mainTableAlias , $ mainTableFields , & $ joinRequired ) { if ( ! is_string ( $ field ) || strpos ( $ field , '.' ) ) { return $ c ; } if ( in_array ( $ field , $ fields ) ) { $ joinRequired = true ; $ field = "$alias.$field" ; } elseif ( in_array ( $ field , $ mainTableFields ) ) { $ field = "$mainTableAlias.$field" ; } return $ c ; } ) ; return $ joinRequired ; }
Iterate over a clause to alias fields

The objective here is to transparently prevent ambiguous field errors by
prefixing fields with the appropriate table alias. This method currently
expects to receive an order clause only.

@param \Cake\ORM\Query $query the query to check
@param string $name The clause name
@param array $config the config to use for adding fields
@return bool Whether a join to the translation table is required
Iterate over a clause to alias fields