0 follower

Final Class Yiisoft\Translator\Message\Db\DbSchemaManager

InheritanceYiisoft\Translator\Message\Db\DbSchemaManager

Manages the translator tables schema in the database.

Public Methods

Hide inherited 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

Hide inherited methods

__construct() public method

public __construct( \Yiisoft\Db\Connection\ConnectionInterface $db ): mixed
$db \Yiisoft\Db\Connection\ConnectionInterface

                public function __construct(private ConnectionInterface $db) {}

            
ensureNoTables() public method

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, {{%yii_source_message}} by default.

$tableMessage string

The name of the locale messages tables, {{%yii_message}} by default.

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();
    }
}

            
ensureTables() public method

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, {{%yii_source_message}} by default.

$tableMessage string

The name of the locale messages table, {{%yii_message}} by default.

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);
}