[TASK] Re-work/simplify copyright header in PHP files - Part 2
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Service / CachingFrameworkDatabaseSchemaService.php
1 <?php
2 namespace TYPO3\CMS\Install\Service;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * This service provides the sql schema for the caching framework
19 */
20 class CachingFrameworkDatabaseSchemaService {
21
22 /**
23 * Get schema SQL of required cache framework tables.
24 *
25 * This method needs ext_localconf and ext_tables loaded!
26 *
27 * This is a hack, but there was no smarter solution with current cache configuration setup:
28 * ToolController sets the extbase caches to NullBackend to ensure the install tool does not
29 * cache anything. The CacheManager gets the required SQL from database backends only, so we need to
30 * temporarily 'fake' the standard db backends for extbase caches so they are respected.
31 *
32 * Additionally, the extbase_object cache is already in use and instantiated, and the CacheManager singleton
33 * does not allow overriding this definition. The only option at the moment is to 'fake' another cache with
34 * a different name, and then substitute this name in the sql content with the real one.
35 *
36 * @TODO: http://forge.typo3.org/issues/54498
37 * @TODO: It might be possible to reduce this ugly construct by circumventing the 'singleton' of CacheManager by using 'new'
38 *
39 * @return string Cache framework SQL
40 */
41 public function getCachingFrameworkRequiredDatabaseSchema() {
42 $cacheConfigurationBackup = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'];
43 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array(
44 'groups' => array('system')
45 );
46 $extbaseObjectFakeName = uniqid('extbase_object');
47 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extbaseObjectFakeName] = array(
48 'groups' => array('system')
49 );
50 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection'] = array(
51 'groups' => array('system')
52 );
53 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array(
54 'groups' => array('system')
55 );
56 /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
57 $cacheManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager');
58 $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
59 $cacheSqlString = \TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions();
60 $sqlString = str_replace($extbaseObjectFakeName, 'extbase_object', $cacheSqlString);
61 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = $cacheConfigurationBackup;
62 $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
63
64 return $sqlString;
65 }
66
67 /**
68 * A slot method to inject the required caching framework database tables to the
69 * tables definitions string
70 *
71 * @param array $sqlString
72 * @return array
73 */
74 public function addCachingFrameworkRequiredDatabaseSchemaToTablesDefinition(array $sqlString) {
75 $sqlString[] = $this->getCachingFrameworkRequiredDatabaseSchema();
76 return array('sqlString' => $sqlString);
77 }
78
79 }