protected function _resultInjector($fetchQuery, $resultMap, $options)
    {
        $keys = $this->associationType === Association::MANY_TO_ONE ?
            $this->foreignKey :
            $this->bindingKey;

        $sourceKeys = [];
        foreach ((array)$keys as $key) {
            $f = $fetchQuery->aliasField($key, $this->sourceAlias);
            $sourceKeys[] = key($f);
        }

        $nestKey = $options['nestKey'];
        if (count($sourceKeys) > 1) {
            return $this->_multiKeysInjector($resultMap, $sourceKeys, $nestKey);
        }

        $sourceKey = $sourceKeys[0];

        return function ($row) use ($resultMap, $sourceKey, $nestKey) {
            if (isset($row[$sourceKey], $resultMap[$row[$sourceKey]])) {
                $row[$nestKey] = $resultMap[$row[$sourceKey]];
            }

            return $row;
        };
    }
protected function _resultInjector($fetchQuery, $resultMap, $options)
    {
        $keys = $this->associationType === Association::MANY_TO_ONE ?
            $this->foreignKey :
            $this->bindingKey;

        $sourceKeys = [];
        foreach ((array)$keys as $key) {
            $f = $fetchQuery->aliasField($key, $this->sourceAlias);
            $sourceKeys[] = key($f);
        }

        $nestKey = $options['nestKey'];
        if (count($sourceKeys) > 1) {
            return $this->_multiKeysInjector($resultMap, $sourceKeys, $nestKey);
        }

        $sourceKey = $sourceKeys[0];

        return function ($row) use ($resultMap, $sourceKey, $nestKey) {
            if (isset($row[$sourceKey], $resultMap[$row[$sourceKey]])) {
                $row[$nestKey] = $resultMap[$row[$sourceKey]];
            }

            return $row;
        };
    }
protected function _resultInjector ( $ fetchQuery , $ resultMap , $ options ) { $ keys = $ this -> associationType === Association :: MANY_TO_ONE ? $ this -> foreignKey : $ this -> bindingKey ; $ sourceKeys = [ ] ; foreach ( ( array ) $ keys as $ key ) { $ f = $ fetchQuery -> aliasField ( $ key , $ this -> sourceAlias ) ; $ sourceKeys [ ] = key ( $ f ) ; } $ nestKey = $ options [ 'nestKey' ] ; if ( count ( $ sourceKeys ) > 1 ) { return $ this -> _multiKeysInjector ( $ resultMap , $ sourceKeys , $ nestKey ) ; } $ sourceKey = $ sourceKeys [ 0 ] ; return function ( $ row ) use ( $ resultMap , $ sourceKey , $ nestKey ) { if ( isset ( $ row [ $ sourceKey ] , $ resultMap [ $ row [ $ sourceKey ] ] ) ) { $ row [ $ nestKey ] = $ resultMap [ $ row [ $ sourceKey ] ] ; } return $ row ; } ; }
Returns a callable to be used for each row in a query result set
for injecting the eager loaded rows

@param \Cake\ORM\Query $fetchQuery the Query used to fetch results
@param array $resultMap an array with the foreignKey as keys and
the corresponding target table results as value.
@param array $options The options passed to the eagerLoader method
@return \Closure
Returns a callable to be used for each row in a query result set for injecting the eager loaded rows