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
Patch
PatchHistory.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Framework\Setup\Patch
;
8
9
use
Magento\Framework\App\ResourceConnection
;
10
14
class
PatchHistory
15
{
19
const
TABLE_NAME
=
'patch_list'
;
20
24
const
CLASS_NAME
=
"patch_name"
;
25
29
const
SCHEMA_PATCH_TYPE
=
'schema'
;
30
34
const
DATA_PATCH_TYPE
=
'data'
;
35
39
private
$patchesRegistry =
null
;
40
44
private
$resourceConnection;
45
50
public
function
__construct
(
ResourceConnection
$resourceConnection)
51
{
52
$this->resourceConnection =
$resourceConnection
;
53
}
54
63
private
function
getAppliedPatches()
64
{
65
if
($this->patchesRegistry ===
null
) {
66
$adapter
= $this->resourceConnection->getConnection();
67
$filterSelect =
$adapter
68
->select()
69
->from($this->resourceConnection->getTableName(self::TABLE_NAME),
self::CLASS_NAME
);
70
$this->patchesRegistry =
$adapter
->fetchCol($filterSelect);
71
}
72
73
return
$this->patchesRegistry;
74
}
75
82
public
function
fixPatch
($patchName)
83
{
84
if
($this->
isApplied
($patchName)) {
85
throw
new \LogicException(sprintf(
"Patch %s cannot be applied twice"
, $patchName));
86
}
87
88
$adapter
= $this->resourceConnection->getConnection();
89
$adapter
->insert($this->resourceConnection->getTableName(self::TABLE_NAME), [self::CLASS_NAME => $patchName]);
90
}
91
98
public
function
revertPatchFromHistory
($patchName)
99
{
100
if
(!$this->
isApplied
($patchName)) {
101
throw
new \LogicException(
102
sprintf(
"Patch %s should be applied, before you can revert it"
, $patchName)
103
);
104
}
105
106
$adapter
= $this->resourceConnection->getConnection();
107
$adapter
->delete(
108
$this->resourceConnection->getTableName(self::TABLE_NAME),
109
[self::CLASS_NAME .
"= ?"
=> $patchName]
110
);
111
}
112
119
public
function
isApplied
($patchName)
120
{
121
return
in_array($patchName, $this->getAppliedPatches());
122
}
123
}
Magento\Framework\Setup\Patch\PatchHistory\CLASS_NAME
const CLASS_NAME
Definition:
PatchHistory.php:24
Magento\Framework\Setup\Patch\PatchHistory\SCHEMA_PATCH_TYPE
const SCHEMA_PATCH_TYPE
Definition:
PatchHistory.php:29
Magento\Framework\Setup\Patch\PatchHistory\isApplied
isApplied($patchName)
Definition:
PatchHistory.php:119
Magento\Framework\Setup\Patch\PatchHistory\fixPatch
fixPatch($patchName)
Definition:
PatchHistory.php:82
$adapter
$adapter
Definition:
webapi_user.php:16
Magento\Framework\Setup\Patch
Definition:
DataPatchInterface.php:6
Magento\Framework\Setup\Patch\PatchHistory\TABLE_NAME
const TABLE_NAME
Definition:
PatchHistory.php:19
$resourceConnection
$resourceConnection
Definition:
website_attribute_sync.php:32
Magento\Framework\App\ResourceConnection
Definition:
ResourceConnection.php:18
Magento\Framework\Setup\Patch\PatchHistory\DATA_PATCH_TYPE
const DATA_PATCH_TYPE
Definition:
PatchHistory.php:34
Magento\Framework\Setup\Patch\PatchHistory\revertPatchFromHistory
revertPatchFromHistory($patchName)
Definition:
PatchHistory.php:98
Magento\Framework\App\ResourceConnection
Magento\Framework\Setup\Patch\PatchHistory
Definition:
PatchHistory.php:14
Magento\Framework\Setup\Patch\PatchHistory\__construct
__construct(ResourceConnection $resourceConnection)
Definition:
PatchHistory.php:50