‪TYPO3CMS  ‪main
FeLoginModeExtractionUpdate.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 
24 
31 #[UpgradeWizard('feLoginModeExtension')]
33 {
34  private const ‪TABLE_NAME = 'pages';
35  private const ‪FIELD_NAME = 'fe_login_mode';
36 
37  public function ‪__construct(private readonly ‪ConnectionPool $connectionPool)
38  {
39  $this->extension = new ‪ExtensionModel(
40  'fe_login_mode',
41  'Removed frontend user login mode functionality',
42  '1.0.0',
43  'o-ba/fe-login-mode',
44  'This extension provides the frontend user login mode functionality, used in previous TYPO3 versions to reduce the amount of cache variants for complex user and group setups.'
45  );
46  }
47 
52  {
53  return new ‪Confirmation(
54  'Are you sure?',
55  'You should install EXT:fe_login_mode only if you really need it. ' . $this->extension->getDescription(),
56  false
57  );
58  }
59 
63  public function ‪getTitle(): string
64  {
65  return 'Install extension "fe_login_mode" from TER';
66  }
67 
71  public function ‪getDescription(): string
72  {
73  return 'To reduce complexity and speed up frontend requests, the rarely used "frontend user login mode"'
74  . ' functionality has been extracted into the TYPO3 Extension Repository. This update downloads the TYPO3'
75  . ' extension fe_login_mode from the TER. Use this if you\'re currently using this functionality.';
76  }
77 
82  public function ‪updateNecessary(): bool
83  {
84  return !‪ExtensionManagementUtility::isLoaded($this->extension->getKey())
85  && $this->‪columnExists()
86  && $this->‪functionalityUsed();
87  }
88 
94  public function ‪getPrerequisites(): array
95  {
96  return [];
97  }
98 
103  protected function ‪columnExists(): bool
104  {
105  $tableColumns = $this->connectionPool
106  ->getConnectionForTable(self::TABLE_NAME)
107  ->createSchemaManager()
108  ->listTableColumns(self::TABLE_NAME);
109  return isset($tableColumns[self::FIELD_NAME]);
110  }
111 
116  protected function ‪functionalityUsed(): bool
117  {
118  $queryBuilder = $this->connectionPool->getQueryBuilderForTable(self::TABLE_NAME);
119  return (bool)$queryBuilder
120  ->count(self::FIELD_NAME)
121  ->from(self::TABLE_NAME)
122  ->where($queryBuilder->expr()->neq(self::FIELD_NAME, 0))
123  ->executeQuery()
124  ->fetchOne();
125  }
126 }
‪TYPO3\CMS\Extensionmanager\Updates\FeLoginModeExtractionUpdate\getConfirmation
‪getConfirmation()
Definition: FeLoginModeExtractionUpdate.php:51
‪TYPO3\CMS\Extensionmanager\Updates\FeLoginModeExtractionUpdate
Definition: FeLoginModeExtractionUpdate.php:33
‪TYPO3\CMS\Extensionmanager\Updates\FeLoginModeExtractionUpdate\columnExists
‪columnExists()
Definition: FeLoginModeExtractionUpdate.php:103
‪TYPO3\CMS\Install\Attribute\UpgradeWizard
Definition: UpgradeWizard.php:25
‪TYPO3\CMS\Extensionmanager\Updates\AbstractDownloadExtensionUpdate
Definition: AbstractDownloadExtensionUpdate.php:37
‪TYPO3\CMS\Extensionmanager\Updates\ExtensionModel
Definition: ExtensionModel.php:27
‪TYPO3\CMS\Extensionmanager\Updates\FeLoginModeExtractionUpdate\functionalityUsed
‪functionalityUsed()
Definition: FeLoginModeExtractionUpdate.php:116
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\isLoaded
‪static isLoaded(string $key)
Definition: ExtensionManagementUtility.php:55
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:32
‪TYPO3\CMS\Extensionmanager\Updates\FeLoginModeExtractionUpdate\getTitle
‪getTitle()
Definition: FeLoginModeExtractionUpdate.php:63
‪TYPO3\CMS\Install\Updates\Confirmation
Definition: Confirmation.php:21
‪TYPO3\CMS\Extensionmanager\Updates\FeLoginModeExtractionUpdate\__construct
‪__construct(private readonly ConnectionPool $connectionPool)
Definition: FeLoginModeExtractionUpdate.php:37
‪TYPO3\CMS\Extensionmanager\Updates\FeLoginModeExtractionUpdate\TABLE_NAME
‪const TABLE_NAME
Definition: FeLoginModeExtractionUpdate.php:34
‪TYPO3\CMS\Extensionmanager\Updates\FeLoginModeExtractionUpdate\FIELD_NAME
‪const FIELD_NAME
Definition: FeLoginModeExtractionUpdate.php:35
‪TYPO3\CMS\Extensionmanager\Updates\FeLoginModeExtractionUpdate\updateNecessary
‪updateNecessary()
Definition: FeLoginModeExtractionUpdate.php:82
‪TYPO3\CMS\Extensionmanager\Updates\FeLoginModeExtractionUpdate\getDescription
‪getDescription()
Definition: FeLoginModeExtractionUpdate.php:71
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Extensionmanager\Updates\FeLoginModeExtractionUpdate\getPrerequisites
‪getPrerequisites()
Definition: FeLoginModeExtractionUpdate.php:94
‪TYPO3\CMS\Extensionmanager\Updates
Definition: AbstractDownloadExtensionUpdate.php:18