Resolves #49142: Add a method to Language Repository
[TYPO3CMS/Extensions/static_info_tables.git] / class.ext_update.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2013 Stanislas Rolland <typo3(arobas)sjbr.ca>
6 * All rights reserved
7 *
8 * This script is part of the Typo3 project. The Typo3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24 /**
25 * Class for updating the db
26 */
27 class ext_update {
28 /**
29 * Main function, returning the HTML content
30 *
31 * @return string HTML
32 */
33 function main() {
34 $content = '';
35
36 $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
37 $databaseUpdateUtility = $objectManager->get('SJBR\\StaticInfoTables\\Utility\\DatabaseUpdateUtility');
38
39 // Clear the class cache
40 $classCacheManager = $objectManager->get('SJBR\\StaticInfoTables\\Cache\\ClassCacheManager');
41 $classCacheManager->reBuild();
42
43 // Get the extensions which want to extend static_info_tables
44 $loadedExtensions = array_unique(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray());
45 foreach ($loadedExtensions as $extensionKey) {
46 $extensionInfoFile = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey) . 'Configuration/DomainModelExtension/StaticInfoTables.txt';
47 if (file_exists($extensionInfoFile)) {
48 $databaseUpdateUtility->doUpdate($extensionKey);
49 $content.= '<p>' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('updateLanguageLabels', 'StaticInfoTables') . ' ' . $extensionKey . '</p>';
50 }
51 }
52 if (!$content) {
53 // Nothing to do
54 $content .= '<p>' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('nothingToDo', 'StaticInfoTables') . '</p>';
55 }
56 return $content;
57 }
58
59 function access() {
60 return TRUE;
61 }
62 }
63 ?>