7 declare(strict_types=1);
29 private $tableResolver;
39 private $tmpTableSuffix =
'_tmp';
44 private $additionalTableSuffix =
'_replica';
49 private $mainTmpTable;
57 TableResolver $tableResolver
60 $this->tableResolver = $tableResolver;
68 private function getConnection()
70 if (!isset($this->connection)) {
71 $this->connection = $this->resource->getConnection();
73 return $this->connection;
82 private function getTable(
$table)
84 return $this->resource->getTableName(
$table);
97 private function createTable($mainTableName, $newTableName)
99 if (!$this->getConnection()->isTableExists($newTableName)) {
100 $this->getConnection()->createTable(
101 $this->getConnection()->createTableByDdl($mainTableName, $newTableName)
115 if ($this->getConnection()->isTableExists(
$tableName)) {
116 $this->getConnection()->dropTable(
$tableName);
153 $mainReplicaTableName = $this->
getMainTable($storeId) . $this->additionalTableSuffix;
157 $mainReplicaTableName
171 $this->dropTable($mainTableName);
173 $mainReplicaTableName = $this->
getMainTable($storeId) . $this->additionalTableSuffix;
174 $this->dropTable($mainReplicaTableName);
186 return $this->
getMainTable($storeId) . $this->additionalTableSuffix;
198 if (!isset($this->mainTmpTable[
$storeId])) {
200 $temporaryTableName = $this->
getMainTable($storeId) . $this->tmpTableSuffix;
201 $this->getConnection()->createTemporaryTableLike($temporaryTableName, $originTableName,
true);
202 $this->mainTmpTable[
$storeId] = $temporaryTableName;
217 if (!isset($this->mainTmpTable[
$storeId])) {
218 throw new \Magento\Framework\Exception\NoSuchEntityException(
'Temporary table does not exist');
220 return $this->mainTmpTable[
$storeId];
getMainTmpTable(int $storeId)
__construct(ResourceConnection $resource, TableResolver $tableResolver)
createTablesForStore(int $storeId)
createMainTmpTable(int $storeId)
getMainReplicaTable(int $storeId)
dropTablesForStore(int $storeId)
getMainTable(int $storeId)