‪TYPO3CMS  9.5
FillTranslationSourceField.php
Go to the documentation of this file.
1 <?php
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 
19 
25 {
29  public function ‪getIdentifier(): string
30  {
31  return 'fillTranslationSourceField';
32  }
33 
37  public function ‪getTitle(): string
38  {
39  return 'Fill translation source field (l10n_source)';
40  }
41 
45  public function ‪getDescription(): string
46  {
47  return 'Fill translation source field (l10n_source) for tt_contents which have l18n_parent set.';
48  }
49 
55  public function ‪updateNecessary(): bool
56  {
57  $connection = GeneralUtility::makeInstance(ConnectionPool::class)
58  ->getConnectionForTable('tt_content');
59  $queryBuilder = $connection->createQueryBuilder();
60  $queryBuilder->getRestrictions()->removeAll();
61  $query = $queryBuilder->count('uid')
62  ->from('tt_content')
63  ->where($queryBuilder->expr()->andX(
64  $queryBuilder->expr()->gt('l18n_parent', $queryBuilder->createNamedParameter(0)),
65  $queryBuilder->expr()->eq('l10n_source', $queryBuilder->createNamedParameter(0))
66  ));
67  return (bool)$query->execute()->fetchColumn(0);
68  }
69 
73  public function ‪getPrerequisites(): array
74  {
75  return [
76  DatabaseUpdatedPrerequisite::class
77  ];
78  }
79 
85  public function ‪executeUpdate(): bool
86  {
87  $connection = GeneralUtility::makeInstance(ConnectionPool::class)
88  ->getConnectionForTable('tt_content');
89  $queryBuilder = $connection->createQueryBuilder();
90  $queryBuilder->getRestrictions()->removeAll();
91  $queryBuilder->update('tt_content', 't')
92  ->set('t.l10n_source', 't.l18n_parent', false)
93  ->where($queryBuilder->expr()->andX(
94  $queryBuilder->expr()->gt('t.l18n_parent', $queryBuilder->createNamedParameter(0)),
95  $queryBuilder->expr()->eq('t.l10n_source', $queryBuilder->createNamedParameter(0))
96  ))
97  ->execute();
98  return true;
99  }
100 }
‪TYPO3\CMS\Install\Updates\FillTranslationSourceField\executeUpdate
‪bool executeUpdate()
Definition: FillTranslationSourceField.php:85
‪TYPO3\CMS\Install\Updates\FillTranslationSourceField\getDescription
‪string getDescription()
Definition: FillTranslationSourceField.php:45
‪TYPO3\CMS\Install\Updates\FillTranslationSourceField\getIdentifier
‪string getIdentifier()
Definition: FillTranslationSourceField.php:29
‪TYPO3\CMS\Install\Updates
Definition: AbstractDownloadExtensionUpdate.php:3
‪TYPO3\CMS\Install\Updates\FillTranslationSourceField
Definition: FillTranslationSourceField.php:25
‪TYPO3\CMS\Install\Updates\FillTranslationSourceField\getTitle
‪string getTitle()
Definition: FillTranslationSourceField.php:37
‪TYPO3\CMS\Install\Updates\UpgradeWizardInterface
Definition: UpgradeWizardInterface.php:22
‪TYPO3\CMS\Install\Updates\FillTranslationSourceField\updateNecessary
‪bool updateNecessary()
Definition: FillTranslationSourceField.php:55
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Install\Updates\FillTranslationSourceField\getPrerequisites
‪string[] getPrerequisites()
Definition: FillTranslationSourceField.php:73