Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] DataStructure Update - Create v11LTS updates from TcaMigration
Related: #372 Release: 8.0.0
- Loading branch information
Alexander Opitz
committed
May 17, 2022
1 parent
c85cb40
commit 64af7df
Showing
5 changed files
with
260 additions
and
1 deletion.
There are no files selected for viewing
202 changes: 202 additions & 0 deletions
202
Classes/Controller/Backend/ControlCenter/Update/DataStructureV11Controller.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
<?php | ||
|
||
namespace Tvp\TemplaVoilaPlus\Controller\Backend\ControlCenter\Update; | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
use Tvp\TemplaVoilaPlus\Utility\TemplaVoilaUtility; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Core\Utility\StringUtility; | ||
|
||
/** | ||
* Controller to migrate/update the DataStructure for TYPO3 v11 LTS | ||
* | ||
* @author Alexander Opitz <opitz@extrameile-gehen.de> | ||
*/ | ||
class DataStructureV11Controller extends AbstractUpdateController | ||
{ | ||
protected $errors = []; | ||
|
||
protected function stepStartAction() | ||
{ | ||
} | ||
|
||
protected function stepFinalAction() | ||
{ | ||
/** @var DataStructureUpdateHandler */ | ||
$handler = GeneralUtility::makeInstance(DataStructureUpdateHandler::class); | ||
$count = $handler->updateAllDs( | ||
[], | ||
[ | ||
[$this, 'migrateColumnsConfig'], | ||
[$this, 'migrateLocalizeChildrenAtParentLocalization'], | ||
[$this, 'removeEnableMultiSelectFilterTextfieldConfiguration'], | ||
[$this, 'migrateSpecialLanguagesToTcaTypeLanguage'], | ||
[$this, 'removeShowRemovedLocalizationRecords'], | ||
[$this, 'migrateFileFolderConfiguration'], | ||
[$this, 'migrateLevelLinksPosition'], | ||
[$this, 'migrateRootUidToStartingPoints'], | ||
] | ||
); | ||
|
||
$this->view->assignMultiple([ | ||
'countStatic' => $countStatic, | ||
'count' => $count, | ||
'errors' => $this->errors, | ||
]); | ||
} | ||
|
||
/** | ||
* Find columns fields that don't have a 'config' section at all, add | ||
* ['config']['type'] = 'none'; for those to enforce config | ||
*/ | ||
public function migrateColumnsConfig(array &$element): bool | ||
{ | ||
$changed = false; | ||
if ((!isset($element['TCEforms']['config']) || !is_array($element['TCEforms']['config'])) && !isset($element['TCEforms']['type'])) { | ||
$element['TCEforms']['config'] = [ | ||
'type' => 'none', | ||
]; | ||
$changed = true; | ||
} | ||
return $changed; | ||
} | ||
|
||
/** | ||
* Option $TCA[$table]['columns'][$columnName]['config']['behaviour']['localizeChildrenAtParentLocalization'] | ||
* is always on, so this option can be removed. | ||
*/ | ||
public function migrateLocalizeChildrenAtParentLocalization(array &$element): bool | ||
{ | ||
$changed = false; | ||
if (isset($element['TCEforms']['config']['behaviour']['localizeChildrenAtParentLocalization'])) { | ||
unset($element['TCEforms']['config']['behaviour']['localizeChildrenAtParentLocalization']); | ||
$changed = true; | ||
} | ||
return $changed; | ||
} | ||
|
||
/** | ||
* Removes configuration removeEnableMultiSelectFilterTextfield | ||
*/ | ||
public function removeEnableMultiSelectFilterTextfieldConfiguration(array &$element): bool | ||
{ | ||
$changed = false; | ||
if (isset($element['TCEforms']['config']['enableMultiSelectFilterTextfield'])) { | ||
unset($element['TCEforms']['config']['enableMultiSelectFilterTextfield']); | ||
$changed = true; | ||
} | ||
return $changed; | ||
} | ||
|
||
/** | ||
* Replaces $TCA[$mytable][columns][field][config][special] = 'languages' with | ||
* $TCA[$mytable][columns][field][config][type] = 'language' | ||
*/ | ||
public function migrateSpecialLanguagesToTcaTypeLanguage(array &$element): bool | ||
{ | ||
$changed = false; | ||
if ((string)($element['TCEforms']['config']['type']) === 'select' | ||
&& (string)($element['TCEforms']['config']['special']) === 'languages' | ||
) { | ||
$element['TCEforms']['config'] = [ | ||
'type' => 'language', | ||
]; | ||
$changed = true; | ||
} | ||
return $changed; | ||
} | ||
|
||
public function removeShowRemovedLocalizationRecords(array &$element): bool | ||
{ | ||
$changed = false; | ||
if ((string)($element['TCEforms']['config']['type']) === 'inline' | ||
&& isset($element['TCEforms']['config']['appearance']['showRemovedLocalizationRecords']) | ||
) { | ||
unset($element['TCEforms']['config']['appearance']['showRemovedLocalizationRecords']); | ||
$changed = true; | ||
} | ||
return $changed; | ||
} | ||
|
||
/** | ||
* Moves the "fileFolder" configuration of TCA columns type=select | ||
* into sub array "fileFolderConfig", while renaming those options. | ||
*/ | ||
public function migrateFileFolderConfiguration(array &$element): bool | ||
{ | ||
$changed = false; | ||
if ((string)($element['TCEforms']['config']['type']) === 'select' | ||
&& isset($element['TCEforms']['config']['fileFolder']) | ||
) { | ||
$element['TCEforms']['config']['fileFolderConfig'] = [ | ||
'folder' => $element['TCEforms']['config']['fileFolder'], | ||
]; | ||
unset($element['TCEforms']['config']['fileFolder']); | ||
if (isset($element['TCEforms']['config']['fileFolder_extList'])) { | ||
$element['TCEforms']['config']['fileFolderConfig']['allowedExtensions'] = $element['TCEforms']['config']['fileFolder_extList']; | ||
unset($element['TCEforms']['config']['fileFolder_extList']); | ||
} | ||
if (isset($element['TCEforms']['config']['fileFolder_recursions'])) { | ||
$element['TCEforms']['config']['fileFolderConfig']['depth'] = $element['TCEforms']['config']['fileFolder_recursions']; | ||
unset($element['TCEforms']['config']['fileFolder_recursions']); | ||
} | ||
$changed = true; | ||
} | ||
|
||
return $changed; | ||
} | ||
|
||
/** | ||
* The [appearance][levelLinksPosition] option can be used | ||
* to select the position of the level links. This option | ||
* was previously misused to disable all those links by | ||
* setting it to "none". Since all of those links can be | ||
* disabled by a dedicated option, e.g. showNewRecordLink, | ||
* this wizard sets those options to false and unsets the | ||
* invalid levelLinksPosition value. | ||
*/ | ||
public function migrateLevelLinksPosition(array &$element): bool | ||
{ | ||
$changed = false; | ||
if ((string)($element['TCEforms']['config']['type']) === 'inline' | ||
&& (string)($element['TCEforms']['config']['appearance']['levelLinksPosition']) === 'none' | ||
) { | ||
unset($element['TCEforms']['config']['appearance']['levelLinksPosition']); | ||
$element['TCEforms']['config']['appearance']['showAllLocalizationLink'] = false; | ||
$element['TCEforms']['config']['appearance']['showSynchronizationLink'] = false; | ||
$element['TCEforms']['config']['appearance']['showNewRecordLink'] = false; | ||
$changed = true; | ||
} | ||
|
||
return $changed; | ||
} | ||
|
||
/** | ||
* If a column has [treeConfig][rootUid] defined, migrate to [treeConfig][startingPoints] on the same level. | ||
*/ | ||
public function migrateRootUidToStartingPoints(array &$element): bool | ||
{ | ||
$changed = false; | ||
if ((int)($element['TCEforms']['config']['treeConfig']['rootUid'] ?? 0) !== 0 | ||
&& in_array((string)($element['TCEforms']['config']['type']), ['select', 'category'], true) | ||
) { | ||
$element['TCEforms']['config']['treeConfig']['startingPoints'] = (string)(int)($element['TCEforms']['config']['treeConfig']['rootUid']); | ||
unset($element['TCEforms']['config']['treeConfig']['rootUid']); | ||
$changed = true; | ||
} | ||
|
||
return $changed; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Resources/Private/Templates/Backend/ControlCenter/Update/DataStructureV11/StepFinal.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{namespace core=TYPO3\CMS\Core\ViewHelpers} | ||
|
||
<div class="callout"> | ||
<h2 class="text-primary">Update DataStructure for usage with TYPO3 v11 LTS</h2> | ||
<h2>Final</h2> | ||
|
||
<f:if condition="{hasError}"> | ||
<f:be.infobox title="Error" state="2"> | ||
<ul class="list-group"> | ||
<f:for each="{errors}" as="validationError"> | ||
<li class="list-group-item list-group-item-danger">{validationError}</li> | ||
</f:for> | ||
</ul> | ||
</f:be.infobox> | ||
</f:if> | ||
|
||
<f:if condition="!{hasError}"> | ||
<p class="lead">All done, you can now return to TV+ Update Script collection</p> | ||
</f:if> | ||
|
||
<div class="row"> | ||
<div class="col-sm-4"> | ||
<f:link.action controller="Backend\ControlCenter\Update" action="info" class="btn btn-primary btn-block btn-lg"> | ||
<core:icon identifier="actions-view-go-back" /> Back to TV+ Update Script collection | ||
</f:link.action> | ||
</div> | ||
<div class="col-sm-4"> | ||
</div> | ||
<div class="col-sm-4"> | ||
</div> | ||
</div> | ||
</form> | ||
</div> |
23 changes: 23 additions & 0 deletions
23
Resources/Private/Templates/Backend/ControlCenter/Update/DataStructureV11/StepStart.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{namespace core=TYPO3\CMS\Core\ViewHelpers} | ||
|
||
<div class="callout"> | ||
<h2 class="text-primary">Update DataStructure for usage with TYPO3 v11 LTS</h2> | ||
<f:be.infobox title="Warning" state="1">Please backup your database/files before running any of the update scripts!</f:be.infobox> | ||
|
||
<p class="lead">This script will update all DataStructures, which are in TemplaVoilà! Plus places, to be useable with TYPO3 v8 LTS. They may not backward compatible afterwards.</p> | ||
|
||
<div class="row"> | ||
<div class="col-sm-4"> | ||
<f:link.action controller="Backend\ControlCenter\Update" action="info" class="btn btn-default btn-block btn-lg"> | ||
<core:icon identifier="actions-view-go-back" /> Back to TV+ Update Script collection | ||
</f:link.action> | ||
</div> | ||
<div class="col-sm-4"> | ||
</div> | ||
<div class="col-sm-4"> | ||
<f:link.action action="stepFinal" class="btn btn-warning btn-block btn-lg"> | ||
<core:icon identifier="actions-view-go-forward" /> Run Update DataStructure from TYPO3 v10 LTS to v11 LTS <small><small>(Version: 1.0.0)</small></small> | ||
</f:link.action> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters