Final Class Yiisoft\Db\Migration\DatabaseRegistry
| Inheritance | Yiisoft\ |
|---|
Additional named databases, in execution order. The "default" database is always configured by the existing command dependencies, so it can't be defined here.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| getNames() | Returns names of additional databases, excluding "default". | Yiisoft\ |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| DEFAULT_DATABASE | 'default' | Reserved name of the default database configured by the existing command dependencies. | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $injector | \ |
|
| $informer | Yiisoft\ |
|
| $databases | array |
Additional named databases, excluding "default". |
public function __construct(
private readonly Injector $injector,
private readonly MigrationInformerInterface $informer,
array $databases = [],
) {
$configs = [];
foreach ($databases as $name => $config) {
if (is_int($name)) {
throw new InvalidArgumentException(
sprintf('Database names must be non-numeric strings, "%s" given.', $name),
);
}
if (trim($name) === '') {
throw new InvalidArgumentException('Database names must be non-empty strings.');
}
if ($name === self::DEFAULT_DATABASE) {
throw new InvalidArgumentException(
sprintf(
'The "%s" database is configured by the existing migration settings and can\'t be redefined.',
self::DEFAULT_DATABASE,
),
);
}
if (!$config instanceof DatabaseConfig) {
throw new InvalidArgumentException(
sprintf(
'Configuration of the "%s" database must be an instance of "%s", "%s" given.',
$name,
DatabaseConfig::class,
get_debug_type($config),
),
);
}
$configs[$name] = $config;
}
$this->configs = $configs;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.