public function attachAssociations(Query $query, Table $repository, $includeFields)
    {
        if (empty($this->_containments) && $this->_matching === null) {
            return;
        }

        $attachable = $this->attachableAssociations($repository);
        $processed = [];
        do {
            foreach ($attachable as $alias => $loadable) {
                $config = $loadable->getConfig() + [
                    'aliasPath' => $loadable->aliasPath(),
                    'propertyPath' => $loadable->propertyPath(),
                    'includeFields' => $includeFields,
                ];
                $loadable->instance()->attachTo($query, $config);
                $processed[$alias] = true;
            }

            $newAttachable = $this->attachableAssociations($repository);
            $attachable = array_diff_key($newAttachable, $processed);
        } while (!empty($attachable));
    }
public function attachAssociations(Query $query, Table $repository, $includeFields)
    {
        if (empty($this->_containments) && $this->_matching === null) {
            return;
        }

        $attachable = $this->attachableAssociations($repository);
        $processed = [];
        do {
            foreach ($attachable as $alias => $loadable) {
                $config = $loadable->getConfig() + [
                    'aliasPath' => $loadable->aliasPath(),
                    'propertyPath' => $loadable->propertyPath(),
                    'includeFields' => $includeFields,
                ];
                $loadable->instance()->attachTo($query, $config);
                $processed[$alias] = true;
            }

            $newAttachable = $this->attachableAssociations($repository);
            $attachable = array_diff_key($newAttachable, $processed);
        } while (!empty($attachable));
    }
public function attachAssociations ( Query $ query , Table $ repository , $ includeFields ) { if ( empty ( $ this -> _containments ) && $ this -> _matching === null ) { return ; } $ attachable = $ this -> attachableAssociations ( $ repository ) ; $ processed = [ ] ; do { foreach ( $ attachable as $ alias => $ loadable ) { $ config = $ loadable -> getConfig ( ) + [ 'aliasPath' => $ loadable -> aliasPath ( ) , 'propertyPath' => $ loadable -> propertyPath ( ) , 'includeFields' => $ includeFields , ] ; $ loadable -> instance ( ) -> attachTo ( $ query , $ config ) ; $ processed [ $ alias ] = true ; } $ newAttachable = $ this -> attachableAssociations ( $ repository ) ; $ attachable = array_diff_key ( $ newAttachable , $ processed ) ; } while ( ! empty ( $ attachable ) ) ; }
Modifies the passed query to apply joins or any other transformation required
in order to eager load the associations described in the `contain` array.
This method will not modify the query for loading external associations, i.e.
those that cannot be loaded without executing a separate query.

@param \Cake\ORM\Query $query The query to be modified
@param \Cake\ORM\Table $repository The repository containing the associations
@param bool $includeFields whether to append all fields from the associations
to the passed query. This can be overridden according to the settings defined
per association in the containments array
@return void
Modifies the passed query to apply joins or any other transformation required in order to eager load the associations described in the contain array . This method will not modify the query for loading external associations i . e . those that cannot be loaded without executing a separate query .