Usage of $GLOBALS['typo3CacheManager'] and $GLOBALS['typo3CacheFactory'] are deprecat...
authorstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 3 Jun 2014 17:31:33 +0000 (17:31 +0000)
committerstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 3 Jun 2014 17:31:33 +0000 (17:31 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/static_info_tables/trunk@85521 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
Classes/Cache/CachedClassLoader.php
Classes/Cache/ClassCacheManager.php
ext_localconf.php

index 0f1d866..b04b10a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
        * Resolves #59300: Missing namespace for InvalidArgumentException
        * Resolves #59301: Missing "searchFields" configuration in ext_tables.php
        * Add localized fields as searchFields next time language pack is (re-)generated
+       * Usage of $GLOBALS['typo3CacheManager'] and $GLOBALS['typo3CacheFactory'] are deprecated since 6.2
 
 2014-04-29  Stanislas Rolland  <typo3@sjbr.ca>
 
index 054b86b..d6997a6 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 namespace SJBR\StaticInfoTables\Cache;
-use \TYPO3\CMS\Core\Utility\GeneralUtility;
 /***************************************************************
  *  Copyright notice
  *
@@ -26,6 +25,9 @@ use \TYPO3\CMS\Core\Utility\GeneralUtility;
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
+use \TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * Cached classes autoloader
  *
@@ -81,9 +83,10 @@ class CachedClassLoader {
                        // Lookup the class in the array of static info entities and check its presence in the class cache
                        $entities = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][static::$extensionKey]['entities'];
                        foreach ($entities as $entity) {
-                               if ($className == static::$namespace . $entity) {
+                               if ($className === static::$namespace . $entity) {
                                        $entryIdentifier = 'DomainModel' . $entity;
-                                       $classCache = $GLOBALS['typo3CacheManager']->getCache(static::$extensionKey);
+                                       $cacheManager = GeneralUtility::makeInstance('TYPO3\CMS\Core\Cache\CacheManager');
+                                       $classCache = $cacheManager->getCache(static::$extensionKey);
                                        if (!$classCache->has($entryIdentifier)) {
                                                // The class cache needs to be rebuilt
                                                $classCacheManager = GeneralUtility::makeInstance('SJBR\\StaticInfoTables\\Cache\\ClassCacheManager');
@@ -95,5 +98,4 @@ class CachedClassLoader {
                        }
                }
        }
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
index 6230bee..399566c 100644 (file)
@@ -19,6 +19,9 @@ namespace SJBR\StaticInfoTables\Cache;
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
+use \TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+use \TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * Class Cache Manager
  *
@@ -50,14 +53,11 @@ class ClassCacheManager {
         * @return void
         */
        protected function initializeCache() {
-               try {
-                       $this->cacheInstance = $GLOBALS['typo3CacheManager']->getCache($this->extensionKey);
-               } catch (\TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException $e) {
-                       $this->cacheInstance = $GLOBALS['typo3CacheFactory']->create(
-                               $this->extensionKey,
-                               $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$this->extensionKey]['frontend'],
-                               $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$this->extensionKey]['backend']
-                       );
+               $cacheManager = GeneralUtility::makeInstance('TYPO3\CMS\Core\Cache\CacheManager');
+               if ($cacheManager->hasCache($this->extensionKey)) {
+                       $this->cacheInstance = $cacheManager->getCache($this->extensionKey);
+               } else {
+                       $this->cacheInstance = $cacheManager->createCache($this->extensionKey);
                }
        }
 
@@ -74,7 +74,7 @@ class ClassCacheManager {
                        $key = 'Domain/Model/' . $entity;
 
                        // Get the file from static_info_tables itself, this needs to be loaded as first
-                       $path = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extensionKey) . 'Classes/' . $key . '.php';
+                       $path = ExtensionManagementUtility::extPath($this->extensionKey) . 'Classes/' . $key . '.php';
                        if (!is_file($path)) {
                                throw new Exception('given file "' . $path . '" does not exist');
                        }
@@ -84,7 +84,7 @@ class ClassCacheManager {
                        if (isset($extensibleExtensions[$key]) && is_array($extensibleExtensions[$key]) && count($extensibleExtensions[$key]) > 0) {
                                $extensionsWithThisClass = array_keys($extensibleExtensions[$key]);
                                foreach ($extensionsWithThisClass as $extension) {
-                                       $path = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extension) . 'Classes/' . $key . '.php';
+                                       $path = ExtensionManagementUtility::extPath($extension) . 'Classes/' . $key . '.php';
                                        if (is_file($path)) {
                                                $code .= $this->parseSingleFile($path);
                                        }
@@ -110,15 +110,15 @@ class ClassCacheManager {
         * @return array
         */
        protected function getExtensibleExtensions() {
-               $loadedExtensions = array_unique(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray());
+               $loadedExtensions = array_unique(ExtensionManagementUtility::getLoadedExtensionListArray());
 
                // Get the extensions which want to extend static_info_tables
                $extensibleExtensions = array();
                foreach ($loadedExtensions as $extensionKey) {
-                       $extensionInfoFile = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey) . 'Configuration/DomainModelExtension/StaticInfoTables.txt';
+                       $extensionInfoFile = ExtensionManagementUtility::extPath($extensionKey) . 'Configuration/DomainModelExtension/StaticInfoTables.txt';
                        if (file_exists($extensionInfoFile)) {
-                               $info = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($extensionInfoFile);
-                               $classes = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $info, TRUE);
+                               $info = GeneralUtility::getUrl($extensionInfoFile);
+                               $classes = GeneralUtility::trimExplode(LF, $info, TRUE);
                                foreach ($classes as $class) {
                                        $extensibleExtensions[$class][$extensionKey] = 1;
                                }
@@ -142,7 +142,7 @@ class ClassCacheManager {
                if (!is_file($filePath)) {
                        throw new InvalidArgumentException(sprintf('File "%s" could not be found', $filePath));
                }
-               $code = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($filePath);
+               $code = GeneralUtility::getUrl($filePath);
                return $this->changeCode($code, $filePath, $removeClassDefinition);
        }
 
@@ -216,7 +216,7 @@ class ClassCacheManager {
                        empty($parameters)
                        || (
                                !empty($parameters['cacheCmd'])
-                               && \TYPO3\CMS\Core\Utility\GeneralUtility::inList('all,temp_cached', $parameters['cacheCmd'])
+                               && GeneralUtility::inList('all,temp_cached', $parameters['cacheCmd'])
                                && isset($GLOBALS['BE_USER'])
                        )
                );
@@ -225,5 +225,4 @@ class ClassCacheManager {
                        $this->build();
                }
        }
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
index 7f054cb..1bbc145 100644 (file)
@@ -23,6 +23,7 @@ $_EXTCONF = unserialize($_EXTCONF);
 // Register cache static_info_tables
 if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$_EXTKEY])) {
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$_EXTKEY] = array();
+       $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$_EXTKEY]['groups'] = array('all');
 }
 if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$_EXTKEY]['frontend'])) {
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$_EXTKEY]['frontend'] = 'TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend';
@@ -110,6 +111,4 @@ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['enableManager'] = isset($_EXTC
 // Make the extension version and constraints available when creating language packs and to other extensions
 require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'ext_emconf.php');
 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['version'] = $EM_CONF[$_EXTKEY]['version'];
-$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['constraints'] = $EM_CONF[$_EXTKEY]['constraints'];
-
-?>
\ No newline at end of file
+$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['constraints'] = $EM_CONF[$_EXTKEY]['constraints'];
\ No newline at end of file