Checks if an association exists.

@throws \RuntimeException If no such association exists for the given table.
@param \Cake\ORM\Table $table Table object.
@param string $association Association name.
@return void
763027
protected function _checkAssociation(Table $table, $association)
    {
        if (!$table->associations()->has($association)) {
            throw new RuntimeException(sprintf('Table `%s` is not associated with `%s`', get_class($table), $association));
        }
    }
404891
private function getClusteredIndex($table)
    {
        foreach ($table->getIndexes() as $index) {
            if ($index->isPrimary() && ! $index->hasFlag('nonclustered')) {
                return $index;
            }

            if ($index->hasFlag('clustered')) {
                return $index;
            }
        }
        throw new RuntimeException('No clustered index found on table ' . $table->getName());
    }
586804
public void setAssociationExecutions(java.util.Collection<AssociationExecution> associationExecutions) {
        if (associationExecutions == null) {
            this.associationExecutions = null;
            return;
        }

        this.associationExecutions = new com.amazonaws.internal.SdkInternalList<AssociationExecution>(associationExecutions);
    }
1031377
public function hasGroup($associated) : bool
    {
        $associated_id = $associated instanceof $this ? $associated->id : $associated;

        return !! $this->group()->where('associated_id', $associated_id)->exists();
    }
149971
public function import(array $tables)
    {
        foreach ($tables as $table => $data) {

            if (!$this->query($this->getSqlCreateTable($table, $data))) {
                throw new RuntimeException("Failed to import database table $table");
            }

            $alter = $this->getSqlAlterTable($table, $data);

            if (!empty($alter) && !$this->query($alter)) {
                throw new RuntimeException("Failed to alter table $table");
            }
        }
    }
53214
public function setTable(Table $table)
    {
        $this->_table = $table;
        $eventManager = $table->getEventManager();
        if ($eventManager !== null) {
            $this->setEventManager($eventManager);
        }
    }
686839
public function hasTable($table) {
        //$sql = $this->grammar->compileTableExists();
        $table = $this->connection->getTablePrefix() . $table;
        return count($this->connection->select(array($table))) > 0;
    }
279742
public function associate($entity)
    {
        $this->parent->setEntityAttribute($this->foreignKey, $entity->getEntityAttribute($this->otherKey));
    }
702587
protected function setRelatedEntityColumnInfo(array &$association, array $fields) {
        $mdataName = implode('.', $fields);
        $lastField = Container::camelize(array_pop($fields));
        $joinName = $this->tableName;
        $entityName = '';
        $columnName = '';

        // loop through the related entities, checking the associations as we go
        $metadata = $this->metadata;
        while ($field = array_shift($fields)) {
            $columnName .= empty($columnName) ? $field : ".$field";
            $entityName = lcfirst(Container::camelize($field));
            if ($metadata->hasAssociation($entityName)) {
                $joinOn = "$joinName.$entityName";
                if ($metadata->isCollectionValuedAssociation($entityName)) {
                    $association['containsCollections'] = true;
                }
                $metadata = $this->em->getClassMetadata(
                    $metadata->getAssociationTargetClass($entityName)
                );
                $joinName .= '_' . $this->getJoinName(
                    $metadata,
                    Container::camelize($metadata->getTableName()),
                    $entityName
                );
                // The join required to get to the entity in question
                if (!isset($this->assignedJoins[$joinName])) {
                    $this->assignedJoins[$joinName]['joinOn'] = $joinOn;
                    $this->assignedJoins[$joinName]['mdataColumn'] = $columnName;
                    $this->identifiers[$joinName] = $metadata->getIdentifierFieldNames();
                }
            }
            else {
                throw new Exception(
                    "Association  '$entityName' not found ($mdataName)",
                    '404'
                );
            }
        }

        // Check the last field on the last related entity of the dotted notation
        if (!$metadata->hasField(lcfirst($lastField))) {
            throw new Exception(
                "Field '$lastField' on association '$entityName' not found ($mdataName)",
                '404'
            );
        }
        $association['entityName'] = $entityName;
        $association['fieldName'] = $lastField;
        $association['joinName'] = $joinName;
        $association['fullName'] = $this->getFullName($association);
    }
755699
private function isSupportedJoinAssociation(Association $association) : bool
    {
        return in_array($association->type(), [Association::MANY_TO_MANY, Association::MANY_TO_ONE]);
    }
1269466
private function getAssociationByField(string $field) : ?Association
    {
        list($name) = explode('.', $this->table->aliasField($field), 2);

        if ($name === $this->table->getAlias()) {
            return null;
        }

        if (! $this->table->hasAssociation($name)) {
            throw new \RuntimeException(sprintf('Table "%s" does not have association "%s"', $this->table->getAlias(), $name));
        }

        return $this->table->getAssociation($name);
    }
810772
public function initialize()
    {
        if ($this->initialized || ! $this->association) {
            return;
        }

        $this->doInitialize();

        $this->initialized = true;
    }
1125992
public function initialize(Table $table)
    {
        $this->table = $table;

        if (!$this->builder instanceof ActionBuilder) {
            $this->builder = new ActionBuilder($this->table);
        }
    }
848890
protected function createTable(Table $table): void
	{
		$table->addPrimaryKey('id')
			->int()
			->setAutoIncrement();
		$table->addForeignKey('pageId', PagesMapper::class);
		$table->addColumn('name')
			->varChar();
		$table->addColumn('position')
			->int(3);
	}
1234630
public function seeTableInDatabase($table)
    {
        $count = $this->_seeTableInDatabase($table);

        $this->assertTrue($count > 0, "No matching tables found for table '" . $table . "' in database.");
    }
1135333
public function loadDataContainer($table)
    {
        if (!$this->database->tableExists($table)) {
            return;
        }

        if (!isset($GLOBALS['TL_DCA'][$table]) || !isset($GLOBALS['TL_DCA'][$table]['config']['treeCache']) || !\is_array($GLOBALS['TL_DCA'][$table]['config']['treeCache'])) {
            return;
        }

        $configurations = $GLOBALS['TL_DCA'][$table]['config']['treeCache'];

        foreach ($configurations as $key => $config) {
            $this->addConfigToTreeCache($table, $key, $config);
        }
    }
891282
private function getParentJoin(Association $association): array
    {
        $table = $association->getTarget();

        $result = [];
        foreach (Utils::getTableAssignationFields($table) as $field) {
            $result[$table->aliasField($field) . ' IN'] = $this->user['id'];
        }

        return $result;
    }