Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ModifyTable.php
Go to the documentation of this file.
1 <?php
8 
15 
22 {
26  const OPERATION_NAME = 'modify_table';
27 
31  private $dbSchemaWriter;
32 
36  public function __construct(DbSchemaWriterInterface $dbSchemaWriter)
37  {
38  $this->dbSchemaWriter = $dbSchemaWriter;
39  }
40 
44  public function getOperationName()
45  {
46  return self::OPERATION_NAME;
47  }
48 
52  public function isOperationDestructive()
53  {
54  return false;
55  }
56 
60  public function doOperation(ElementHistory $elementHistory)
61  {
63  $table = $elementHistory->getNew();
65  $oldTable = $elementHistory->getOld();
66  $oldOptions = $oldTable->getDiffSensitiveParams();
67  $statements = [];
68 
69  foreach ($table->getDiffSensitiveParams() as $optionName => $optionValue) {
70  if ($oldOptions[$optionName] !== $optionValue) {
71  $statements[] = $this->dbSchemaWriter->modifyTableOption(
72  $table->getName(),
73  $table->getResource(),
74  $optionName,
76  );
77  }
78  }
79 
80  return $statements;
81  }
82 }
$oldOptions
__construct(DbSchemaWriterInterface $dbSchemaWriter)
Definition: ModifyTable.php:36
$table
Definition: trigger.php:14