Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
framework
Setup
Declaration
Schema
Db
MySQL
DDL
Triggers
MigrateDataFromAnotherTable.php
Go to the documentation of this file.
1
<?php
7
declare(strict_types=1);
8
9
namespace
Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DDL\Triggers
;
10
11
use
Magento\Framework\App\ResourceConnection
;
12
use
Magento\Framework\Setup\Declaration\Schema\Db\DDLTriggerInterface
;
13
use
Magento\Framework\Setup\Declaration\Schema\Dto\Table
;
14
use
Magento\Framework\Setup\Declaration\Schema\ElementHistory
;
15
19
class
MigrateDataFromAnotherTable
implements
DDLTriggerInterface
20
{
24
const
MATCH_PATTERN
=
'/migrateDataFromAnotherTable\(([^\)]+)\)/'
;
25
29
private
$resourceConnection;
30
36
public
function
__construct
(
ResourceConnection
$resourceConnection)
37
{
38
$this->resourceConnection =
$resourceConnection
;
39
}
40
44
public
function
isApplicable
(
string
$statement) : bool
45
{
46
return
(
bool
) preg_match(self::MATCH_PATTERN, $statement);
47
}
48
52
public
function
getCallback
(
ElementHistory
$tableHistory) : callable
53
{
55
$table
= $tableHistory->
getNew
();
56
preg_match(self::MATCH_PATTERN,
$table
->getOnCreate(), $matches);
57
return
function
() use (
$table
, $matches) {
58
$tableName
=
$table
->getName();
59
$oldTableName = $this->resourceConnection->getTableName($matches[1]);
60
$adapter
= $this->resourceConnection->getConnection(
$table
->getResource());
61
$select
=
$adapter
->select()->from($oldTableName);
62
$adapter
->query(
$adapter
->insertFromSelect(
$select
,
$tableName
));
63
};
64
}
65
}
Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DDL\Triggers\MigrateDataFromAnotherTable\isApplicable
isApplicable(string $statement)
Definition:
MigrateDataFromAnotherTable.php:44
Magento\Framework\Setup\Declaration\Schema\ElementHistory\getNew
getNew()
Definition:
ElementHistory.php:55
$tableName
$tableName
Definition:
trigger.php:13
Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DDL\Triggers\MigrateDataFromAnotherTable
Definition:
MigrateDataFromAnotherTable.php:19
Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DDL\Triggers\MigrateDataFromAnotherTable\__construct
__construct(ResourceConnection $resourceConnection)
Definition:
MigrateDataFromAnotherTable.php:36
Magento\Framework\Setup\Declaration\Schema\Db\DDLTriggerInterface
Definition:
DDLTriggerInterface.php:29
Magento\Framework\Setup\Declaration\Schema\Dto\Table
Definition:
Table.php:17
Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DDL\Triggers
Definition:
MigrateDataBetweenShards.php:9
$adapter
$adapter
Definition:
webapi_user.php:16
$select
$select
Definition:
catalog_rule_10_off_not_logged_rollback.php:14
Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DDL\Triggers\MigrateDataFromAnotherTable\MATCH_PATTERN
const MATCH_PATTERN
Definition:
MigrateDataFromAnotherTable.php:24
Magento\Framework\Setup\Declaration\Schema\ElementHistory
Definition:
ElementHistory.php:16
Magento\Framework\Setup\Declaration\Schema\Db\DDLTriggerInterface\getCallback
getCallback(ElementHistory $elementHistory)
$resourceConnection
$resourceConnection
Definition:
website_attribute_sync.php:32
Magento\Framework\App\ResourceConnection
Definition:
ResourceConnection.php:18
$table
$table
Definition:
trigger.php:14
Magento\Framework\App\ResourceConnection