‪TYPO3CMS  11.5
L18nDiffsourceToJsonMigration.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
7 /*
8  * This file is part of the TYPO3 CMS project.
9  *
10  * It is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License, either version 2
12  * of the License, or any later version.
13  *
14  * For the full copyright and license information, please read the
15  * LICENSE.txt file that was distributed with this source code.
16  *
17  * The TYPO3 project - inspiring people to share!
18  */
19 
20 use TYPO3\CMS\Backend\Utility\BackendUtility;
21 
29 {
30  public function ‪getTitle(): string
31  {
32  return 'Migrate transOrigDiffSourceField field to json encoded string.';
33  }
34 
35  public function ‪hasPotentialUpdateForTable(string $tableName): bool
36  {
37  return BackendUtility::isTableLocalizable($tableName) && !empty(‪$GLOBALS['TCA'][$tableName]['ctrl']['transOrigDiffSourceField']);
38  }
39 
40  public function ‪updateTableRow(string $tableName, array $row): array
41  {
42  $fieldName = ‪$GLOBALS['TCA'][$tableName]['ctrl']['transOrigDiffSourceField'];
43  if (
44  !empty($row[$fieldName])
45  && is_scalar($row[$fieldName])
46  && ($fieldContent = @unserialize((string)$row[$fieldName], ['allowed_classes' => false])) !== false
47  ) {
48  if (is_object($fieldContent)) {
49  $row[$fieldName] = null;
50  } else {
51  $row[$fieldName] = json_encode($fieldContent);
52  }
53  }
54  return $row;
55  }
56 }
‪TYPO3\CMS\Install\Updates\RowUpdater\L18nDiffsourceToJsonMigration\getTitle
‪getTitle()
Definition: L18nDiffsourceToJsonMigration.php:30
‪TYPO3\CMS\Install\Updates\RowUpdater\L18nDiffsourceToJsonMigration\updateTableRow
‪updateTableRow(string $tableName, array $row)
Definition: L18nDiffsourceToJsonMigration.php:40
‪TYPO3\CMS\Install\Updates\RowUpdater\RowUpdaterInterface
Definition: RowUpdaterInterface.php:24
‪TYPO3\CMS\Install\Updates\RowUpdater
Definition: L18nDiffsourceToJsonMigration.php:5
‪TYPO3\CMS\Install\Updates\RowUpdater\L18nDiffsourceToJsonMigration
Definition: L18nDiffsourceToJsonMigration.php:29
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Install\Updates\RowUpdater\L18nDiffsourceToJsonMigration\hasPotentialUpdateForTable
‪hasPotentialUpdateForTable(string $tableName)
Definition: L18nDiffsourceToJsonMigration.php:35