‪TYPO3CMS  9.5
MigrateFscStaticTemplateUpdate.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 'migrateFscStaticTemplateUpdate';
32  }
33 
37  public function ‪getTitle(): string
38  {
39  return 'Migrate "fluid_styled_content" static template location';
40  }
41 
45  public function ‪getDescription(): string
46  {
47  return 'Static templates have been relocated to EXT:fluid_styled_content/Configuration/TypoScript/';
48  }
49 
55  public function ‪updateNecessary(): bool
56  {
57  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_template');
58  $queryBuilder->getRestrictions()->removeAll();
59  $elementCount = $queryBuilder->count('uid')
60  ->from('sys_template')
61  ->where(
62  $queryBuilder->expr()->orX(
63  $queryBuilder->expr()->like(
64  'constants',
65  $queryBuilder->createNamedParameter('%EXT:fluid_styled_content/Configuration/TypoScript/Static%', \PDO::PARAM_STR)
66  ),
67  $queryBuilder->expr()->like(
68  'config',
69  $queryBuilder->createNamedParameter('%EXT:fluid_styled_content/Configuration/TypoScript/Static%', \PDO::PARAM_STR)
70  ),
71  $queryBuilder->expr()->like(
72  'include_static_file',
73  $queryBuilder->createNamedParameter('%EXT:fluid_styled_content/Configuration/TypoScript/Static%', \PDO::PARAM_STR)
74  )
75  )
76  )
77  ->execute()->fetchColumn(0);
78  return (bool)$elementCount;
79  }
80 
84  public function ‪getPrerequisites(): array
85  {
86  return [
87  DatabaseUpdatedPrerequisite::class
88  ];
89  }
90 
96  public function ‪executeUpdate(): bool
97  {
98  $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('sys_template');
99  $queryBuilder = $connection->createQueryBuilder();
100  $queryBuilder->getRestrictions()->removeAll();
101  $statement = $queryBuilder->select('uid', 'include_static_file', 'constants', 'config')
102  ->from('sys_template')
103  ->where(
104  $queryBuilder->expr()->orX(
105  $queryBuilder->expr()->like(
106  'constants',
107  $queryBuilder->createNamedParameter('%EXT:fluid_styled_content/Configuration/TypoScript/Static%', \PDO::PARAM_STR)
108  ),
109  $queryBuilder->expr()->like(
110  'config',
111  $queryBuilder->createNamedParameter('%EXT:fluid_styled_content/Configuration/TypoScript/Static%', \PDO::PARAM_STR)
112  ),
113  $queryBuilder->expr()->like(
114  'include_static_file',
115  $queryBuilder->createNamedParameter('%EXT:fluid_styled_content/Configuration/TypoScript/Static%', \PDO::PARAM_STR)
116  )
117  )
118  )
119  ->execute();
120  while ($record = $statement->fetch()) {
121  $search = 'EXT:fluid_styled_content/Configuration/TypoScript/Static';
122  $replace = 'EXT:fluid_styled_content/Configuration/TypoScript';
123  $record['include_static_file'] = str_replace($search, $replace, $record['include_static_file']);
124  $record['constants'] = str_replace($search, $replace, $record['constants']);
125  $record['config'] = str_replace($search, $replace, $record['config']);
126  $queryBuilder = $connection->createQueryBuilder();
127  $queryBuilder->update('sys_template')
128  ->where(
129  $queryBuilder->expr()->eq(
130  'uid',
131  $queryBuilder->createNamedParameter($record['uid'], \PDO::PARAM_INT)
132  )
133  )
134  ->set('include_static_file', $record['include_static_file'])
135  ->set('constants', $record['constants'])
136  ->set('config', $record['config']);
137  $queryBuilder->execute();
138  }
139  return true;
140  }
141 }
‪TYPO3\CMS\Install\Updates\MigrateFscStaticTemplateUpdate\getTitle
‪string getTitle()
Definition: MigrateFscStaticTemplateUpdate.php:37
‪TYPO3\CMS\Install\Updates\MigrateFscStaticTemplateUpdate\updateNecessary
‪bool updateNecessary()
Definition: MigrateFscStaticTemplateUpdate.php:55
‪TYPO3\CMS\Install\Updates\MigrateFscStaticTemplateUpdate\getDescription
‪string getDescription()
Definition: MigrateFscStaticTemplateUpdate.php:45
‪TYPO3\CMS\Install\Updates\MigrateFscStaticTemplateUpdate
Definition: MigrateFscStaticTemplateUpdate.php:25
‪TYPO3\CMS\Install\Updates
Definition: AbstractDownloadExtensionUpdate.php:3
‪TYPO3\CMS\Install\Updates\MigrateFscStaticTemplateUpdate\getPrerequisites
‪string[] getPrerequisites()
Definition: MigrateFscStaticTemplateUpdate.php:84
‪TYPO3\CMS\Install\Updates\MigrateFscStaticTemplateUpdate\executeUpdate
‪bool executeUpdate()
Definition: MigrateFscStaticTemplateUpdate.php:96
‪TYPO3\CMS\Install\Updates\MigrateFscStaticTemplateUpdate\getIdentifier
‪string getIdentifier()
Definition: MigrateFscStaticTemplateUpdate.php:29
‪TYPO3\CMS\Install\Updates\UpgradeWizardInterface
Definition: UpgradeWizardInterface.php:22
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45