‪TYPO3CMS  11.5
CollectionsExtractionUpdate.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 
23 
29 {
33  protected ‪$extension;
34 
38  protected ‪$confirmation;
39 
40  public function ‪__construct()
41  {
42  $this->extension = new ‪ExtensionModel(
43  'legacy_collections',
44  'sys_collection Database APIs',
45  '1.0.0',
46  'friendsoftypo3/legacy-collections',
47  'Re-Adds previously available sys_collection database tables'
48  );
49 
50  $this->confirmation = new ‪Confirmation(
51  'Are you sure?',
52  'This API has not been used very often, only install it if you have entries in your sys_collection database table. ' . $this->extension->getDescription(),
53  false
54  );
55  }
56 
62  public function ‪getConfirmation(): ‪Confirmation
63  {
65  }
66 
73  public function ‪getIdentifier(): string
74  {
75  return 'legacyCollectionsExtension';
76  }
77 
83  public function ‪getTitle(): string
84  {
85  return 'Install extension "legacy_collections" from TER for sys_collection database records';
86  }
87 
93  public function ‪getDescription(): string
94  {
95  return 'The extension "legacy_collections" re-adds the database tables sys_collection_* and its TCA definition, if this was previously in use.';
96  }
97 
104  public function ‪updateNecessary(): bool
105  {
106  // Extension already activated, nothing to do
107  if (‪ExtensionManagementUtility::isLoaded('legacy_collections')) {
108  return true;
109  }
110  // Check if database table exist
111  $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
112  $connection = $connectionPool->getConnectionByName('Default');
113  $tableNames = $connection->createSchemaManager()->listTableNames();
114  if (in_array('sys_collection', $tableNames, true)) {
115  // table is available, now check if there are entries in it
116  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
117  ->getQueryBuilderForTable('sys_collection');
118  $numberOfEntries = $queryBuilder->count('*')
119  ->from('sys_collection')
120  ->executeQuery()
121  ->fetchOne();
122  return (bool)$numberOfEntries;
123  }
124 
125  return false;
126  }
127 
135  public function ‪getPrerequisites(): array
136  {
137  return [
138  DatabaseUpdatedPrerequisite::class,
139  ];
140  }
141 }
‪TYPO3\CMS\Install\Updates\CollectionsExtractionUpdate\getDescription
‪string getDescription()
Definition: CollectionsExtractionUpdate.php:91
‪TYPO3\CMS\Install\Updates
Definition: AbstractDownloadExtensionUpdate.php:16
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:43
‪TYPO3\CMS\Install\Updates\CollectionsExtractionUpdate\getPrerequisites
‪string[] getPrerequisites()
Definition: CollectionsExtractionUpdate.php:133
‪TYPO3\CMS\Install\Updates\CollectionsExtractionUpdate
Definition: CollectionsExtractionUpdate.php:29
‪TYPO3\CMS\Install\Updates\ExtensionModel
Definition: ExtensionModel.php:26
‪TYPO3\CMS\Install\Updates\CollectionsExtractionUpdate\updateNecessary
‪bool updateNecessary()
Definition: CollectionsExtractionUpdate.php:102
‪TYPO3\CMS\Install\Updates\CollectionsExtractionUpdate\$confirmation
‪Confirmation $confirmation
Definition: CollectionsExtractionUpdate.php:36
‪TYPO3\CMS\Install\Updates\Confirmation
Definition: Confirmation.php:21
‪TYPO3\CMS\Install\Updates\CollectionsExtractionUpdate\__construct
‪__construct()
Definition: CollectionsExtractionUpdate.php:38
‪TYPO3\CMS\Install\Updates\CollectionsExtractionUpdate\getTitle
‪string getTitle()
Definition: CollectionsExtractionUpdate.php:81
‪TYPO3\CMS\Install\Updates\AbstractDownloadExtensionUpdate
Definition: AbstractDownloadExtensionUpdate.php:32
‪TYPO3\CMS\Install\Updates\CollectionsExtractionUpdate\$extension
‪ExtensionModel $extension
Definition: CollectionsExtractionUpdate.php:32
‪TYPO3\CMS\Install\Updates\CollectionsExtractionUpdate\getConfirmation
‪Confirmation getConfirmation()
Definition: CollectionsExtractionUpdate.php:60
‪TYPO3\CMS\Install\Updates\CollectionsExtractionUpdate\getIdentifier
‪string getIdentifier()
Definition: CollectionsExtractionUpdate.php:71
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\isLoaded
‪static bool isLoaded($key)
Definition: ExtensionManagementUtility.php:114