‪TYPO3CMS  10.4
MigrateFeloginPluginsCtype.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
28 
33 {
34  protected const ‪CTYPE_PIBASE = 'login';
35  protected const ‪CTYPE_EXTBASE = 'felogin_login';
36 
43  public function ‪getIdentifier(): string
44  {
45  return self::class;
46  }
47 
53  public function ‪getTitle(): string
54  {
55  return 'Migrate felogin plugins to use extbase CType';
56  }
57 
63  public function ‪getDescription(): string
64  {
65  return 'This wizard migrates existing front end plugins of the extension felogin from piBase key to ' .
66  'the new Extbase "CType"';
67  }
68 
76  public function ‪executeUpdate(): bool
77  {
78  // Get all tt_content data for login plugins and update their CTypes and Flexforms settings
79  $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tt_content');
80 
82  $queryBuilder = $connection->createQueryBuilder();
83  $queryBuilder
84  ->update('tt_content')
85  ->set('CType', $this->‪getNewCType())
86  ->where(
87  $queryBuilder->expr()->eq(
88  'CType',
89  $queryBuilder->createNamedParameter($this->getOldCType())
90  )
91  )
92  ->execute();
93 
94  return true;
95  }
96 
105  public function ‪updateNecessary(): bool
106  {
108  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
109  $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
110  $elementCount = $queryBuilder->count('uid')
111  ->from('tt_content')
112  ->where(
113  $queryBuilder->expr()->eq('CType', $queryBuilder->createNamedParameter($this->getOldCType()))
114  )
115  ->execute()->fetchColumn();
116 
117  return (bool)$elementCount;
118  }
119 
128  public function ‪getPrerequisites(): array
129  {
130  return [
131  MigrateFeloginPlugins::class
132  ];
133  }
134 
140  protected function ‪isExtbaseFeatureEnabled(): bool
141  {
142  return GeneralUtility::makeInstance(Features::class)
143  ->isFeatureEnabled('felogin.extbase');
144  }
145 
151  protected function ‪getOldCType(): string
152  {
154  }
155 
161  protected function ‪getNewCType(): string
162  {
164  }
165 }
‪TYPO3\CMS\Install\Updates\RepeatableInterface
Definition: RepeatableInterface.php:26
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\getOldCType
‪string getOldCType()
Definition: MigrateFeloginPluginsCtype.php:151
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\getTitle
‪string getTitle()
Definition: MigrateFeloginPluginsCtype.php:53
‪TYPO3\CMS\Felogin\Updates\MigrateFeloginPlugins
Definition: MigrateFeloginPlugins.php:31
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\CTYPE_EXTBASE
‪const CTYPE_EXTBASE
Definition: MigrateFeloginPluginsCtype.php:35
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\getDescription
‪string getDescription()
Definition: MigrateFeloginPluginsCtype.php:63
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\getNewCType
‪string getNewCType()
Definition: MigrateFeloginPluginsCtype.php:161
‪TYPO3\CMS\Core\Database\Query\QueryBuilder
Definition: QueryBuilder.php:52
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\getPrerequisites
‪string[] getPrerequisites()
Definition: MigrateFeloginPluginsCtype.php:128
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype
Definition: MigrateFeloginPluginsCtype.php:33
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\isExtbaseFeatureEnabled
‪bool isExtbaseFeatureEnabled()
Definition: MigrateFeloginPluginsCtype.php:140
‪TYPO3\CMS\Core\Configuration\Features
Definition: Features.php:56
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\updateNecessary
‪bool updateNecessary()
Definition: MigrateFeloginPluginsCtype.php:105
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\CTYPE_PIBASE
‪const CTYPE_PIBASE
Definition: MigrateFeloginPluginsCtype.php:34
‪TYPO3\CMS\FrontendLogin\Updates
Definition: MigrateFeloginPluginsCtype.php:18
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\getIdentifier
‪string getIdentifier()
Definition: MigrateFeloginPluginsCtype.php:43
‪TYPO3\CMS\Install\Updates\UpgradeWizardInterface
Definition: UpgradeWizardInterface.php:24
‪TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
Definition: DeletedRestriction.php:28
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\executeUpdate
‪bool executeUpdate()
Definition: MigrateFeloginPluginsCtype.php:76
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46