‪TYPO3CMS  9.5
BulletContentElementUpdate.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 'bulletContentElementUpdate';
32  }
33 
37  public function ‪getTitle(): string
38  {
39  return 'Migrate bullet content element rendering selector from layout to bullets_type';
40  }
41 
45  public function ‪getDescription(): string
46  {
47  return 'Rendering type field has been streamlined with fluid_styled_content.';
48  }
49 
55  public function ‪updateNecessary(): bool
56  {
57  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
58  $queryBuilder->getRestrictions()->removeAll();
59  $elementCount = $queryBuilder->count('uid')
60  ->from('tt_content')
61  ->where(
62  $queryBuilder->expr()->eq('CType', $queryBuilder->createNamedParameter('bullets', \PDO::PARAM_STR)),
63  $queryBuilder->expr()->in('layout', [1, 2])
64  )
65  ->execute()
66  ->fetchColumn(0);
67  return (bool)$elementCount;
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)->getConnectionForTable('tt_content');
88  $queryBuilder = $connection->createQueryBuilder();
89  $queryBuilder->getRestrictions()->removeAll();
90  $statement = $queryBuilder->select('uid', 'layout')
91  ->from('tt_content')
92  ->where(
93  $queryBuilder->expr()->eq('CType', $queryBuilder->createNamedParameter('bullets', \PDO::PARAM_STR)),
94  $queryBuilder->expr()->in('layout', [1, 2])
95  )
96  ->execute();
97  while ($record = $statement->fetch()) {
98  $queryBuilder = $connection->createQueryBuilder();
99  $queryBuilder->update('tt_content')
100  ->where(
101  $queryBuilder->expr()->eq(
102  'uid',
103  $queryBuilder->createNamedParameter($record['uid'], \PDO::PARAM_INT)
104  )
105  )
106  ->set('layout', 0, false)
107  ->set('bullets_type', $record['layout']);
108  $queryBuilder->execute();
109  }
110  return true;
111  }
112 }
‪TYPO3\CMS\Install\Updates\BulletContentElementUpdate
Definition: BulletContentElementUpdate.php:25
‪TYPO3\CMS\Install\Updates\BulletContentElementUpdate\getDescription
‪string getDescription()
Definition: BulletContentElementUpdate.php:45
‪TYPO3\CMS\Install\Updates\BulletContentElementUpdate\updateNecessary
‪bool updateNecessary()
Definition: BulletContentElementUpdate.php:55
‪TYPO3\CMS\Install\Updates\BulletContentElementUpdate\getIdentifier
‪string getIdentifier()
Definition: BulletContentElementUpdate.php:29
‪TYPO3\CMS\Install\Updates
Definition: AbstractDownloadExtensionUpdate.php:3
‪TYPO3\CMS\Install\Updates\BulletContentElementUpdate\executeUpdate
‪bool executeUpdate()
Definition: BulletContentElementUpdate.php:85
‪TYPO3\CMS\Install\Updates\UpgradeWizardInterface
Definition: UpgradeWizardInterface.php:22
‪TYPO3\CMS\Install\Updates\BulletContentElementUpdate\getPrerequisites
‪string[] getPrerequisites()
Definition: BulletContentElementUpdate.php:73
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Install\Updates\BulletContentElementUpdate\getTitle
‪string getTitle()
Definition: BulletContentElementUpdate.php:37
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45