‪TYPO3CMS  11.5
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 
25 
30 {
31  protected const ‪CTYPE_PIBASE = 'login';
32  protected const ‪CTYPE_EXTBASE = 'felogin_login';
33 
40  public function ‪getIdentifier(): string
41  {
42  return self::class;
43  }
44 
50  public function ‪getTitle(): string
51  {
52  return 'Migrate felogin plugins to use extbase CType';
53  }
54 
60  public function ‪getDescription(): string
61  {
62  return 'This wizard migrates existing front end plugins of the extension felogin from piBase key to ' .
63  'the new Extbase "CType"';
64  }
65 
73  public function ‪executeUpdate(): bool
74  {
75  // Get all tt_content data for login plugins and update their CTypes and Flexforms settings
76  $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tt_content');
77 
78  $queryBuilder = $connection->createQueryBuilder();
79  $queryBuilder
80  ->update('tt_content')
81  ->set('CType', $this->‪getNewCType())
82  ->where(
83  $queryBuilder->expr()->eq(
84  'CType',
85  $queryBuilder->createNamedParameter($this->getOldCType())
86  )
87  )
88  ->execute();
89 
90  return true;
91  }
92 
101  public function ‪updateNecessary(): bool
102  {
103  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
104  $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
105  $elementCount = $queryBuilder->count('uid')
106  ->from('tt_content')
107  ->where(
108  $queryBuilder->expr()->eq('CType', $queryBuilder->createNamedParameter($this->getOldCType()))
109  )
110  ->execute()->fetchOne();
111 
112  return (bool)$elementCount;
113  }
114 
123  public function ‪getPrerequisites(): array
124  {
125  return [
126  MigrateFeloginPlugins::class,
127  ];
128  }
129 
135  protected function ‪getOldCType(): string
136  {
137  return ‪self::CTYPE_PIBASE;
138  }
139 
145  protected function ‪getNewCType(): string
146  {
147  return ‪self::CTYPE_EXTBASE;
148  }
149 }
‪TYPO3\CMS\Install\Updates\RepeatableInterface
Definition: RepeatableInterface.php:25
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\getOldCType
‪string getOldCType()
Definition: MigrateFeloginPluginsCtype.php:135
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\getTitle
‪string getTitle()
Definition: MigrateFeloginPluginsCtype.php:50
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\CTYPE_EXTBASE
‪const CTYPE_EXTBASE
Definition: MigrateFeloginPluginsCtype.php:32
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\getDescription
‪string getDescription()
Definition: MigrateFeloginPluginsCtype.php:60
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\getNewCType
‪string getNewCType()
Definition: MigrateFeloginPluginsCtype.php:145
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\getPrerequisites
‪string[] getPrerequisites()
Definition: MigrateFeloginPluginsCtype.php:123
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype
Definition: MigrateFeloginPluginsCtype.php:30
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\updateNecessary
‪bool updateNecessary()
Definition: MigrateFeloginPluginsCtype.php:101
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\CTYPE_PIBASE
‪const CTYPE_PIBASE
Definition: MigrateFeloginPluginsCtype.php:31
‪TYPO3\CMS\FrontendLogin\Updates
Definition: MigrateFeloginPlugins.php:18
‪TYPO3\CMS\FrontendLogin\Updates\MigrateFeloginPluginsCtype\getIdentifier
‪string getIdentifier()
Definition: MigrateFeloginPluginsCtype.php:40
‪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:73
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50