getForeignTableName example



    private function getForeignKey(Connection $connection, string $relationTable): ?ForeignKeyConstraint
    {
        $foreignKeys = $connection->createSchemaManager()->listTableForeignKeys($relationTable);

        foreach ($foreignKeys as $foreignKey) {
            if (!$foreignKey instanceof ForeignKeyConstraint) {
                continue;
            }

            if ($foreignKey->getForeignTableName() === 'salutation' && $foreignKey->getLocalColumns() === ['salutation_id']) {
                return $foreignKey;
            }
        }

        return null;
    }
}

    protected function getPropertyNameOfColumnName($table$column)
    {
        $foreignKey = $this->getColumnForeignKey($table$column);
        if ($foreignKey instanceof \Doctrine\DBAL\Schema\ForeignKeyConstraint) {
            $table = $foreignKey->getForeignTableName();

            $fullName = $this->getClassNameOfTableName($table);

            return lcfirst($fullName) . 'Id';
        }

        return lcfirst($this->underscoreToCamelCase($column->getName()));
    }

    /** * Converts underscore separated string into a camelCase separated string * * @param string $str * * @return string */

    private function validateForeignKeyOnDeleteBehaviour(EntityDefinition $definition, OneToManyAssociationField|ManyToManyAssociationField $association, EntityDefinition $reference, array $associationViolations): array
    {
        $manager = $this->connection->createSchemaManager();

        if ($association->getFlag(CascadeDelete::class)
            || $association->getFlag(RestrictDelete::class)
            || $association->getFlag(SetNullOnDelete::class)) {
            $fks = $manager->listTableForeignKeys($reference->getEntityName());

            foreach ($fks as $fk) {
                if ($fk->getForeignTableName() !== $definition->getEntityName() || !\in_array($association->getReferenceField()$fk->getLocalColumns(), true)) {
                    continue;
                }

                $deleteFlag = $association->getFlag(CascadeDelete::class)
                    ?? $association->getFlag(RestrictDelete::class)
                    ?? $association->getFlag(SetNullOnDelete::class);

                if (!$deleteFlag instanceof Flag) {
                    continue;
                }

                
return array_values($playbook);
    }

    private function implodeColumns(array $columns): string
    {
        return implode(',', array_map(fn (string $column): string => '`' . $column . '`', $columns));
    }

    private function isEqualForeignKey(ForeignKeyConstraint $constraint, string $foreignTable, array $foreignFieldNames): bool
    {
        if ($constraint->getForeignTableName() !== $foreignTable) {
            return false;
        }

        return \count(array_diff($constraint->getForeignColumns()$foreignFieldNames)) === 0;
    }

    private function hydrateForeignKeyData(array $data, string $keyColumnName): array
    {
        $hydratedData = $this->mapHydrateForeignKeyData($data);

        return $this->filterHydrateForeignKeyData($hydratedData$keyColumnName);
    }
Home | Imprint | This part of the site doesn't use cookies.