Final Class Yiisoft\Translator\Message\Db\DbSchemaManager
| Inheritance | Yiisoft\Translator\Message\Db\DbSchemaManager |
|---|
Manages the translator tables schema in the database.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Translator\Message\Db\DbSchemaManager | |
| ensureNoTables() | Ensures that the translator tables does not exist in the database. | Yiisoft\Translator\Message\Db\DbSchemaManager |
| ensureTables() | Ensures that the translator tables exists in the database. | Yiisoft\Translator\Message\Db\DbSchemaManager |
Method Details
| public __construct( \Yiisoft\Db\Connection\ConnectionInterface $db ): mixed | ||
| $db | \Yiisoft\Db\Connection\ConnectionInterface | |
public function __construct(private ConnectionInterface $db) {}
Ensures that the translator tables does not exist in the database.
| public ensureNoTables( string $tableSourceMessage = '{{%yii_source_message}}', string $tableMessage = '{{%yii_message}}' ): void | ||
| $tableSourceMessage | string |
The name of the source messages tables, |
| $tableMessage | string |
The name of the locale messages tables, |
| throws | \Yiisoft\Db\Exception\Exception | |
|---|---|---|
| throws | \Yiisoft\Db\Exception\InvalidConfigException | |
| throws | Throwable | |
public function ensureNoTables(
string $tableSourceMessage = '{{%yii_source_message}}',
string $tableMessage = '{{%yii_message}}',
): void {
$schema = $this->db->getSchema();
$quoter = $this->db->getQuoter();
$tableRawNameSourceMessage = $quoter->getRawTableName($tableSourceMessage);
$tableRawNameMessage = $quoter->getRawTableName($tableMessage);
if ($schema->hasTable($tableRawNameMessage, refresh: true)) {
// drop table `yii_message`.
$this->db->createCommand()->dropTable($tableRawNameMessage)->execute();
}
if ($schema->hasTable($tableRawNameSourceMessage)) {
// drop table `yii_source_message`.
$this->db->createCommand()->dropTable($tableRawNameSourceMessage)->execute();
}
}
Ensures that the translator tables exists in the database.
| public ensureTables( string $tableSourceMessage = '{{%yii_source_message}}', string $tableMessage = '{{%yii_message}}' ): void | ||
| $tableSourceMessage | string |
The name of the source messages table, |
| $tableMessage | string |
The name of the locale messages table, |
| throws | \Yiisoft\Db\Exception\Exception | |
|---|---|---|
| throws | \Yiisoft\Db\Exception\InvalidConfigException | |
| throws | Throwable | |
public function ensureTables(
string $tableSourceMessage = '{{%yii_source_message}}',
string $tableMessage = '{{%yii_message}}',
): void {
$schema = $this->db->getSchema();
$quoter = $this->db->getQuoter();
$tableRawNameSourceMessage = $quoter->getRawTableName($tableSourceMessage);
$tableRawNameMessage = $quoter->getRawTableName($tableMessage);
if ($schema->hasTable($tableRawNameSourceMessage, refresh: true)
&& $schema->hasTable($tableRawNameMessage)
) {
return;
}
$this->createSchema($tableRawNameSourceMessage, $tableRawNameMessage);
}
Signup or Login in order to comment.