Cake\ORM\Query::_addAssociationsToTypeMap PHP Method

_addAssociationsToTypeMap() protected method

Used to recursively add contained association column types to the query.
protected _addAssociationsToTypeMap ( Table $table, Cake\Database\TypeMap $typeMap, array $associations ) : void
$table Table The table instance to pluck associations from.
$typeMap Cake\Database\TypeMap The typemap to check for columns in. This typemap is indirectly mutated via Cake\ORM\Query::addDefaultTypes()
$associations array The nested tree of associations to walk.
return void
    protected function _addAssociationsToTypeMap($table, $typeMap, $associations)
    {
        foreach ($associations as $name => $nested) {
            $association = $table->association($name);
            if (!$association) {
                continue;
            }
            $target = $association->target();
            $primary = (array) $target->primaryKey();
            if (empty($primary) || $typeMap->type($target->aliasField($primary[0])) === null) {
                $this->addDefaultTypes($target);
            }
            if (!empty($nested)) {
                $this->_addAssociationsToTypeMap($target, $typeMap, $nested);
            }
        }
    }