[TASK] Migrate extension update script to TYPO3 LTS 9
[TYPO3CMS/Extensions/static_info_tables.git] / ext_localconf.php
1 <?php
2 defined('TYPO3_MODE') or die();
3
4 call_user_func(
5 function($extKey)
6 {
7 // Get the extensions's configuration
8 if (class_exists(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)) {
9 $extConf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get($extKey);
10 } else {
11 $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extKey]);
12 }
13 // Register cache static_info_tables
14 if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extKey])) {
15 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extKey] = [];
16 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extKey]['groups'] = ['all'];
17 }
18 if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['static_info_tables']['frontend'])) {
19 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extKey]['frontend'] = \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend::class;
20 }
21 if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['static_info_tables']['backend'])) {
22 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extKey]['backend'] = \TYPO3\CMS\Core\Cache\Backend\FileBackend::class;
23 }
24 // Configure clear cache post processing for extended domain model
25 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']['static_info_tables'] = \SJBR\StaticInfoTables\Cache\ClassCacheManager::class . '->reBuild';
26 // Names of static entities
27 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$extKey]['entities'] = ['Country', 'CountryZone', 'Currency', 'Language', 'Territory'];
28 // Register cached domain model classes autoloader
29 require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extKey) . 'Classes/Cache/CachedClassLoader.php');
30 \SJBR\StaticInfoTables\Cache\CachedClassLoader::registerAutoloader();
31 // Possible label fields for different languages. Default as last.
32 $labelTable = [
33 'static_territories' => [
34 'label_fields' => [
35 'tr_name_##', 'tr_name_en',
36 ],
37 'isocode_field' => [
38 'tr_iso_##',
39 ]
40 ],
41 'static_countries' => [
42 'label_fields' => [
43 'cn_short_##', 'cn_short_en',
44 ],
45 'isocode_field' => [
46 'cn_iso_##',
47 ]
48 ],
49 'static_country_zones' => [
50 'label_fields' => [
51 'zn_name_##', 'zn_name_local',
52 ],
53 'isocode_field' => [
54 'zn_code', 'zn_country_iso_##',
55 ]
56 ],
57 'static_languages' => [
58 'label_fields' => [
59 'lg_name_##', 'lg_name_en',
60 ],
61 'isocode_field' => [
62 'lg_iso_##', 'lg_country_iso_##',
63 ]
64 ],
65 'static_currencies' => [
66 'label_fields' => [
67 'cu_name_##', 'cu_name_en',
68 ],
69 'isocode_field' => [
70 'cu_iso_##',
71 ]
72 ]
73 ];
74 if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$extKey]['tables']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$extKey]['tables'])) {
75 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$extKey]['tables'] = array_merge($labelTable, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$extKey]['tables']);
76 } else {
77 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$extKey]['tables'] = $labelTable;
78 }
79 // Add data handling hook to manage ISO codes redundancies on records
80 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = \SJBR\StaticInfoTables\Hook\Core\DataHandling\ProcessDataMap::class;
81 // Register slot for AfterExtensionInstall signal
82 $dispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
83 $dispatcher->connect(\TYPO3\CMS\Extensionmanager\Utility\InstallUtility::class, 'afterExtensionInstall', \SJBR\StaticInfoTables\Slot\Extensionmanager\AfterExtensionInstall::class, 'executeUpdateScript');
84 // Enabling the Static Info Tables Manager module
85 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$extKey]['enableManager'] = isset($extConf['enableManager']) ? $extConf['enableManager'] : '0';
86 // Make the extension version and constraints available when creating language packs and to other extensions
87 $emConfUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extensionmanager\Utility\EmConfUtility::class);
88 $emConf = $emConfUtility->includeEmConf(['key' => $extKey, 'siteRelPath' => \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extKey))]);
89 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$extKey]['version'] = $emConf[$extKey]['version'];
90 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$extKey]['constraints'] = $emConf[$extKey]['constraints'];
91 // Configure translation of suggestions labels
92 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $extKey . '/Configuration/PageTSconfig/Suggest.tsconfig">');
93 if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getNumericTypo3Version()) < 9000000) {
94 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList::class]['buildQueryParameters'][] = \SJBR\StaticInfoTables\Hook\Backend\Recordlist\BuildQueryParameters::class;
95 } else {
96 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList::class]['modifyQuery'][] = \SJBR\StaticInfoTables\Hook\Backend\Recordlist\ModifyQuery::class;
97 }
98 },
99 'static_info_tables'
100 );