TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
AbstractDatabaseSchemaUpdate.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Install\Updates;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use Doctrine\DBAL\Schema\SchemaDiff;
21 
26 {
31 
32  protected $listTemplate = '
33  <p>%1$s</p>
34  <fieldset>
35  <ol class="t3-install-form-label-after">%2$s</ol>
36  </fieldset>
37  ';
38 
44  protected $fieldListItem = '
45  <li class="labelAfter">
46  <label><strong>%1$s</strong>: %2$s</label>
47  </li>
48  ';
49 
55  protected $tableListItem = '
56  <li class="labelAfter">
57  <label><strong>%1$s</strong></label>
58  </li>
59  ';
60 
68  {
69  $this->schemaMigrationService = $schemaMigrationService ?: GeneralUtility::makeInstance(
70  SchemaMigrator::class
71  );
72  }
73 
87  protected function getDatabaseDifferences(): array
88  {
89  $statements = $this->getDatabaseDefinition();
90 
91  return $this->schemaMigrationService->getSchemaDiffs($statements);
92  }
93 
103  protected function getDatabaseDefinition(): array
104  {
105  $sqlReader = GeneralUtility::makeInstance(SqlReader::class);
106 
107  return $sqlReader->getCreateTableStatementArray($sqlReader->getTablesDefinitionString());
108  }
109 
115  protected function renderFieldListItem(string $tableName, string $fieldName): string
116  {
117  return sprintf($this->fieldListItem, $tableName, $fieldName);
118  }
119 
124  protected function renderTableListItem(string $tableName): string
125  {
126  return sprintf($this->tableListItem, $tableName);
127  }
128 
134  protected function renderList(string $label, string $items): string
135  {
136  if (trim($items) === '') {
137  return '';
138  }
139 
140  return sprintf($this->listTemplate, $label, $items);
141  }
142 }
static makeInstance($className,...$constructorArguments)
__construct(SchemaMigrator $schemaMigrationService=null)