protected function _resolveJoins($associations, $matching = [])
    {
        $result = [];
        foreach ($matching as $table => $loadable) {
            $result[$table] = $loadable;
            $result += $this->_resolveJoins($loadable->associations(), []);
        }
        foreach ($associations as $table => $loadable) {
            $inMatching = isset($matching[$table]);
            if (!$inMatching && $loadable->canBeJoined()) {
                $result[$table] = $loadable;
                $result += $this->_resolveJoins($loadable->associations(), []);
                continue;
            }

            if ($inMatching) {
                $this->_correctStrategy($loadable);
            }

            $loadable->setCanBeJoined(false);
            $this->_loadExternal[] = $loadable;
        }

        return $result;
    }
protected function _resolveJoins($associations, $matching = [])
    {
        $result = [];
        foreach ($matching as $table => $loadable) {
            $result[$table] = $loadable;
            $result += $this->_resolveJoins($loadable->associations(), []);
        }
        foreach ($associations as $table => $loadable) {
            $inMatching = isset($matching[$table]);
            if (!$inMatching && $loadable->canBeJoined()) {
                $result[$table] = $loadable;
                $result += $this->_resolveJoins($loadable->associations(), []);
                continue;
            }

            if ($inMatching) {
                $this->_correctStrategy($loadable);
            }

            $loadable->setCanBeJoined(false);
            $this->_loadExternal[] = $loadable;
        }

        return $result;
    }
protected function _resolveJoins ( $ associations , $ matching = [ ] ) { $ result = [ ] ; foreach ( $ matching as $ table => $ loadable ) { $ result [ $ table ] = $ loadable ; $ result += $ this -> _resolveJoins ( $ loadable -> associations ( ) , [ ] ) ; } foreach ( $ associations as $ table => $ loadable ) { $ inMatching = isset ( $ matching [ $ table ] ) ; if ( ! $ inMatching && $ loadable -> canBeJoined ( ) ) { $ result [ $ table ] = $ loadable ; $ result += $ this -> _resolveJoins ( $ loadable -> associations ( ) , [ ] ) ; continue ; } if ( $ inMatching ) { $ this -> _correctStrategy ( $ loadable ) ; } $ loadable -> setCanBeJoined ( false ) ; $ this -> _loadExternal [ ] = $ loadable ; } return $ result ; }
Helper function used to compile a list of all associations that can be
joined in the query.

@param array $associations list of associations from which to obtain joins.
@param array $matching list of associations that should be forcibly joined.
@return array
Helper function used to compile a list of all associations that can be joined in the query .