Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
PatchHistory Class Reference

Public Member Functions

 __construct (ResourceConnection $resourceConnection)
 
 fixPatch ($patchName)
 
 revertPatchFromHistory ($patchName)
 
 isApplied ($patchName)
 

Data Fields

const TABLE_NAME = 'patch_list'
 
const CLASS_NAME = "patch_name"
 
const SCHEMA_PATCH_TYPE = 'schema'
 
const DATA_PATCH_TYPE = 'data'
 

Detailed Description

This is registry of all patches, that are already applied on database

Definition at line 14 of file PatchHistory.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ResourceConnection  $resourceConnection)

PatchHistory constructor.

Parameters
ResourceConnection$resourceConnection

Definition at line 50 of file PatchHistory.php.

51  {
52  $this->resourceConnection = $resourceConnection;
53  }

Member Function Documentation

◆ fixPatch()

fixPatch (   $patchName)

Fix patch in patch table in order to avoid reapplying of patch

Parameters
string$patchName
Returns
void

Definition at line 82 of file PatchHistory.php.

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  }
$adapter
Definition: webapi_user.php:16

◆ isApplied()

isApplied (   $patchName)

Check whether patch was applied on the system or not

Parameters
string$patchName
Returns
bool

Definition at line 119 of file PatchHistory.php.

120  {
121  return in_array($patchName, $this->getAppliedPatches());
122  }

◆ revertPatchFromHistory()

revertPatchFromHistory (   $patchName)

Revert patch from history

Parameters
$patchName
Returns
void

Definition at line 98 of file PatchHistory.php.

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  }
$adapter
Definition: webapi_user.php:16

Field Documentation

◆ CLASS_NAME

const CLASS_NAME = "patch_name"

Name of a patch

Definition at line 24 of file PatchHistory.php.

◆ DATA_PATCH_TYPE

const DATA_PATCH_TYPE = 'data'

Patch type for data patches

Definition at line 34 of file PatchHistory.php.

◆ SCHEMA_PATCH_TYPE

const SCHEMA_PATCH_TYPE = 'schema'

Patch type for schema patches

Definition at line 29 of file PatchHistory.php.

◆ TABLE_NAME

const TABLE_NAME = 'patch_list'

Table name where patche names will be persisted

Definition at line 19 of file PatchHistory.php.


The documentation for this class was generated from the following file: