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
MigrateDataFrom.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DDL\Triggers
;
9
10
use
Magento\Framework\App\ResourceConnection
;
11
use
Magento\Framework\DB\Sql\Expression
;
12
use
Magento\Framework\Setup\Declaration\Schema\Db\DDLTriggerInterface
;
13
use
Magento\Framework\Setup\Declaration\Schema\Dto\Column
;
14
use
Magento\Framework\Setup\Declaration\Schema\ElementHistory
;
15
20
class
MigrateDataFrom
implements
DDLTriggerInterface
21
{
25
const
MATCH_PATTERN
=
'/migrateDataFrom\(([^\)]+)\)/'
;
26
30
private
$resourceConnection;
31
37
public
function
__construct
(
ResourceConnection
$resourceConnection)
38
{
39
$this->resourceConnection =
$resourceConnection
;
40
}
41
45
public
function
isApplicable
(
string
$statement) : bool
46
{
47
return
(
bool
) preg_match(self::MATCH_PATTERN, $statement);
48
}
49
53
public
function
getCallback
(
ElementHistory
$columnHistory) : callable
54
{
56
$column = $columnHistory->
getNew
();
57
preg_match(self::MATCH_PATTERN, $column->getOnCreate(), $matches);
58
return
function
() use ($column, $matches) {
59
$tableName
= $column->getTable()->getName();
60
$adapter
= $this->resourceConnection->getConnection(
61
$column->getTable()->getResource()
62
);
63
$adapter
64
->update(
65
$this->resourceConnection->getTableName(
$tableName
),
66
[
67
$column->getName() =>
new
Expression
($matches[1])
68
]
69
);
70
};
71
}
72
}
Magento\Framework\Setup\Declaration\Schema\Dto\Column
Definition:
Column.php:11
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\MigrateDataFrom\MATCH_PATTERN
const MATCH_PATTERN
Definition:
MigrateDataFrom.php:25
Magento\Framework\Setup\Declaration\Schema\Db\DDLTriggerInterface
Definition:
DDLTriggerInterface.php:29
Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DDL\Triggers
Definition:
MigrateDataBetweenShards.php:9
$adapter
$adapter
Definition:
webapi_user.php:16
Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DDL\Triggers\MigrateDataFrom
Definition:
MigrateDataFrom.php:20
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
Magento\Framework\App\ResourceConnection
Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DDL\Triggers\MigrateDataFrom\__construct
__construct(ResourceConnection $resourceConnection)
Definition:
MigrateDataFrom.php:37
Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DDL\Triggers\MigrateDataFrom\isApplicable
isApplicable(string $statement)
Definition:
MigrateDataFrom.php:45
Magento\Framework\DB\Sql\Expression
Definition:
Expression.php:11