| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace Doctrine\DBAL\Schema\Exception;
|
|
|
6 |
|
|
|
7 |
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
|
|
|
8 |
use Doctrine\DBAL\Schema\SchemaException;
|
|
|
9 |
use Doctrine\DBAL\Schema\Table;
|
|
|
10 |
|
|
|
11 |
use function implode;
|
|
|
12 |
use function sprintf;
|
|
|
13 |
|
|
|
14 |
/** @psalm-immutable */
|
|
|
15 |
final class NamedForeignKeyRequired extends SchemaException
|
|
|
16 |
{
|
|
|
17 |
public static function new(Table $localTable, ForeignKeyConstraint $foreignKey): self
|
|
|
18 |
{
|
|
|
19 |
return new self(
|
|
|
20 |
sprintf(
|
|
|
21 |
'The performed schema operation on "%s" requires a named foreign key, ' .
|
|
|
22 |
'but the given foreign key from (%s) onto foreign table "%s" (%s) is currently unnamed.',
|
|
|
23 |
$localTable->getName(),
|
|
|
24 |
implode(', ', $foreignKey->getColumns()),
|
|
|
25 |
$foreignKey->getForeignTableName(),
|
|
|
26 |
implode(', ', $foreignKey->getForeignColumns()),
|
|
|
27 |
),
|
|
|
28 |
);
|
|
|
29 |
}
|
|
|
30 |
}
|