TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
Comparator.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types=1);
3 namespace TYPO3\CMS\Core\Database\Schema;
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 use Doctrine\DBAL\Schema\Table;
20 
26 class Comparator extends \Doctrine\DBAL\Schema\Comparator
27 {
38  public function diffTable(Table $fromTable, Table $toTable)
39  {
40  $newTableOptions = array_merge($fromTable->getOptions(), $toTable->getOptions());
41  $optionDiff = array_diff_assoc($newTableOptions, $fromTable->getOptions());
42  $tableDifferences = parent::diffTable($fromTable, $toTable);
43 
44  // No changed table options, return parent result
45  if (count($optionDiff) === 0) {
46  return $tableDifferences;
47  }
48 
49  if ($tableDifferences === false) {
50  $tableDifferences = GeneralUtility::makeInstance(TableDiff::class, $fromTable->getName());
51  $tableDifferences->fromTable = $fromTable;
52  } else {
53  // Rebuild TableDiff with enhanced TYPO3 TableDiff class
54  $tableDifferences = GeneralUtility::makeInstance(
55  TableDiff::class,
56  $tableDifferences->name,
57  $tableDifferences->addedColumns,
58  $tableDifferences->changedColumns,
59  $tableDifferences->removedColumns,
60  $tableDifferences->addedIndexes,
61  $tableDifferences->changedIndexes,
62  $tableDifferences->removedIndexes,
63  $tableDifferences->fromTable
64  );
65  }
66 
67  // Set the table options to be parsed in the AlterTable event.
68  $tableDifferences->setTableOptions($optionDiff);
69 
70  return $tableDifferences;
71  }
72 }
static makeInstance($className,...$constructorArguments)
diffTable(Table $fromTable, Table $toTable)
Definition: Comparator.php:38