[TASK] Migrate to static::class (require PHP 5.5 now)
authorTim Lochmüller <tim@fruit-lab.de>
Tue, 29 Dec 2015 09:33:15 +0000 (10:33 +0100)
committerTim Lochmüller <tim@fruit-lab.de>
Tue, 29 Dec 2015 09:33:15 +0000 (10:33 +0100)
Change-Id: I9dd7409dbacf68bd5fff88806a6ff82c10492081

Classes/Cache/AbstractBackend.php
Classes/Cache/Rule/Enable.php
Classes/Cache/StaticFileBackend.php
Classes/Module/CacheModule.php
Classes/StaticFileCache.php
Classes/Utility/CacheUtility.php
ext_emconf.php
ext_localconf.php
ext_tables.php

index 7ee1d6d..bee19f9 100644 (file)
@@ -8,6 +8,7 @@
 
 namespace SFC\NcStaticfilecache\Cache;
 
+use SFC\NcStaticfilecache\Configuration;
 use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -29,7 +30,7 @@ class AbstractBackend extends Typo3DatabaseBackend
     /**
      * Configuration
      *
-     * @var \SFC\NcStaticfilecache\Configuration
+     * @var Configuration
      */
     protected $configuration;
 
@@ -42,7 +43,7 @@ class AbstractBackend extends Typo3DatabaseBackend
     public function __construct($context, array $options = [])
     {
         parent::__construct($context, $options);
-        $this->configuration = GeneralUtility::makeInstance('SFC\\NcStaticfilecache\\Configuration');
+        $this->configuration = GeneralUtility::makeInstance(Configuration::class);
     }
 
     /**
index e12a5a7..2a6179a 100644 (file)
@@ -33,7 +33,7 @@ class Enable extends AbstractRule
     public function checkRule($frontendController, $uri, &$explanation, &$skipProcessing)
     {
         /** @var Configuration $configuration */
-        $configuration = GeneralUtility::makeInstance('SFC\\NcStaticfilecache\\Configuration');
+        $configuration = GeneralUtility::makeInstance(Configuration::class);
         if ((boolean)$configuration->get('disableCache') === true) {
             $explanation[__CLASS__] = 'static cache disabled by TypoScript';
         }
index 01f9e9f..4147ce0 100644 (file)
@@ -94,7 +94,7 @@ class StaticFileBackend extends AbstractBackend
             $lifetime = $accessTimeout ? $accessTimeout : $this->getRealLifetime($lifetime);
 
             /** @var StandaloneView $renderer */
-            $renderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
+            $renderer = GeneralUtility::makeInstance(StandaloneView::class);
             $renderer->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:nc_staticfilecache/Resources/Private/Templates/Htaccess.html'));
             $renderer->assignMultiple([
                 'mode' => $accessTimeout ? 'A' : 'M',
index 17844ed..f604bc6 100644 (file)
@@ -45,7 +45,7 @@ class CacheModule extends AbstractFunctionModule
 
         // Initialize tree object:
         /* @var $tree BrowseTreeView */
-        $tree = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\BrowseTreeView');
+        $tree = GeneralUtility::makeInstance(BrowseTreeView::class);
         $tree->makeHTML = 2;
         $tree->init();
 
@@ -110,7 +110,7 @@ class CacheModule extends AbstractFunctionModule
         }
 
         /** @var StandaloneView $renderer */
-        $renderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
+        $renderer = GeneralUtility::makeInstance(StandaloneView::class);
         $renderer->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:nc_staticfilecache/Resources/Private/Templates/Module.html'));
         $renderer->assignMultiple([
             'requestUri' => GeneralUtility::getIndpEnv('REQUEST_URI'),
index 03c813c..4739900 100644 (file)
@@ -56,7 +56,7 @@ class StaticFileCache implements SingletonInterface
      */
     public static function getInstance()
     {
-        return GeneralUtility::makeInstance('SFC\\NcStaticfilecache\\StaticFileCache');
+        return GeneralUtility::makeInstance(StaticFileCache::class);
     }
 
     /**
@@ -65,8 +65,8 @@ class StaticFileCache implements SingletonInterface
     public function __construct()
     {
         $this->cache = CacheUtility::getCache();
-        $this->signalDispatcher = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
-        $this->configuration = GeneralUtility::makeInstance('SFC\\NcStaticfilecache\\Configuration');
+        $this->signalDispatcher = GeneralUtility::makeInstance(Dispatcher::class);
+        $this->configuration = GeneralUtility::makeInstance(Configuration::class);
     }
 
     /**
@@ -196,7 +196,7 @@ class StaticFileCache implements SingletonInterface
     {
         $objectManager = new ObjectManager();
         /** @var UriBuilder $uriBuilder */
-        $uriBuilder = $objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
+        $uriBuilder = $objectManager->get(UriBuilder::class);
         if (ObjectAccess::getProperty($uriBuilder, 'contentObject', true) === null) {
             // there are situations without a valid contentObject in the URI builder
             // prevent this situation by return the original request URI
index d7fb7d0..df42200 100644 (file)
@@ -28,7 +28,7 @@ class CacheUtility
     {
         /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
         $objectManager = new ObjectManager();
-        $cacheManager = $objectManager->get('TYPO3\\CMS\\Core\\Cache\\CacheManager');
+        $cacheManager = $objectManager->get(CacheManager::class);
         return $cacheManager->getCache('static_file_cache');
     }
 
index ecc0146..a8f9f26 100644 (file)
@@ -24,6 +24,7 @@ $EM_CONF[$_EXTKEY] = [
     'constraints' => [
         'depends' => [
             'typo3' => '6.2.0-7.99.99',
+            'php' => '5.5.0-0.0.0',
         ],
     ],
 ];
index ea600b2..a08bbef 100644 (file)
@@ -11,51 +11,45 @@ if (!defined('TYPO3_MODE')) {
 // Register with "crawler" extension:
 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['procInstructions']['tx_ncstaticfilecache_clearstaticfile'] = 'clear static cache file';
 
-$hookNamespace = 'SFC\\NcStaticfilecache\\Hook\\';
-
 // Hook to process clearing static cached files if "crawler" extension is active:
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'][$_EXTKEY] = $hookNamespace . 'Crawler->clearStaticFile';
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache'][$_EXTKEY] = \SFC\NcStaticfilecache\Hook\Crawler::class . '->clearStaticFile';
 
 // Log a cache miss if no_cache is true
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'][$_EXTKEY] = $hookNamespace . 'LogNoCache->log';
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'][$_EXTKEY] = \SFC\NcStaticfilecache\Hook\LogNoCache::class . '->log';
 
 // Create cache
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'][$_EXTKEY] = 'SFC\\NcStaticfilecache\\StaticFileCache';
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache'][$_EXTKEY] = \SFC\NcStaticfilecache\StaticFileCache::class;
 
 // Set cookie when User logs in
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'][$_EXTKEY] = $hookNamespace . 'InitFrontendUser->setFeUserCookie';
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_post_processing'][$_EXTKEY] = $hookNamespace . 'LogoffFrontendUser->logoff';
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'][$_EXTKEY] = \SFC\NcStaticfilecache\Hook\InitFrontendUser::class . '->setFeUserCookie';
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_post_processing'][$_EXTKEY] = \SFC\NcStaticfilecache\Hook\LogoffFrontendUser::class . '->logoff';
 
 // register command controller
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'SFC\\NcStaticfilecache\\Command\\CacheCommandController';
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = \SFC\NcStaticfilecache\Command\CacheCommandController::class;
+
+$ruleClasses = [
+    \SFC\NcStaticfilecache\Cache\Rule\StaticCacheable::class,
+    \SFC\NcStaticfilecache\Cache\Rule\ValidUri::class,
+    \SFC\NcStaticfilecache\Cache\Rule\ValidDoktype::class,
+    \SFC\NcStaticfilecache\Cache\Rule\NoWorkspacePreview::class,
+    \SFC\NcStaticfilecache\Cache\Rule\NoUserOrGroupSet::class,
+    \SFC\NcStaticfilecache\Cache\Rule\NoIntScripts::class,
+    \SFC\NcStaticfilecache\Cache\Rule\LoginDeniedConfiguration::class,
+    \SFC\NcStaticfilecache\Cache\Rule\PageCacheable::class,
+    \SFC\NcStaticfilecache\Cache\Rule\NoNoCache::class,
+    \SFC\NcStaticfilecache\Cache\Rule\Enable::class,
+];
 
 /** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */
-$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
-$signalSlotDispatcher->connect('SFC\\NcStaticfilecache\\StaticFileCache', 'cacheRule',
-    'SFC\\NcStaticfilecache\\Cache\\Rule\\StaticCacheable', 'check');
-$signalSlotDispatcher->connect('SFC\\NcStaticfilecache\\StaticFileCache', 'cacheRule',
-    'SFC\\NcStaticfilecache\\Cache\\Rule\\ValidUri', 'check');
-$signalSlotDispatcher->connect('SFC\\NcStaticfilecache\\StaticFileCache', 'cacheRule',
-    'SFC\\NcStaticfilecache\\Cache\\Rule\\ValidDoktype', 'check');
-$signalSlotDispatcher->connect('SFC\\NcStaticfilecache\\StaticFileCache', 'cacheRule',
-    'SFC\\NcStaticfilecache\\Cache\\Rule\\NoWorkspacePreview', 'check');
-$signalSlotDispatcher->connect('SFC\\NcStaticfilecache\\StaticFileCache', 'cacheRule',
-    'SFC\\NcStaticfilecache\\Cache\\Rule\\NoUserOrGroupSet', 'check');
-$signalSlotDispatcher->connect('SFC\\NcStaticfilecache\\StaticFileCache', 'cacheRule',
-    'SFC\\NcStaticfilecache\\Cache\\Rule\\NoIntScripts', 'check');
-$signalSlotDispatcher->connect('SFC\\NcStaticfilecache\\StaticFileCache', 'cacheRule',
-    'SFC\\NcStaticfilecache\\Cache\\Rule\\LoginDeniedConfiguration', 'check');
-$signalSlotDispatcher->connect('SFC\\NcStaticfilecache\\StaticFileCache', 'cacheRule',
-    'SFC\\NcStaticfilecache\\Cache\\Rule\\PageCacheable', 'check');
-$signalSlotDispatcher->connect('SFC\\NcStaticfilecache\\StaticFileCache', 'cacheRule',
-    'SFC\\NcStaticfilecache\\Cache\\Rule\\NoNoCache', 'check');
-$signalSlotDispatcher->connect('SFC\\NcStaticfilecache\\StaticFileCache', 'cacheRule',
-    'SFC\\NcStaticfilecache\\Cache\\Rule\\Enable', 'check');
+$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
+foreach($ruleClasses as $class){
+    $signalSlotDispatcher->connect(\SFC\NcStaticfilecache\StaticFileCache::class, 'cacheRule', $class, 'check');
+}
 
 // new Cache for Static file caches
 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['static_file_cache'] = [
-    'frontend' => 'SFC\\NcStaticfilecache\\Cache\\UriFrontend',
-    'backend' => 'SFC\\NcStaticfilecache\\Cache\\StaticFileBackend',
+    'frontend' => \SFC\NcStaticfilecache\Cache\UriFrontend::class,
+    'backend' => \SFC\NcStaticfilecache\Cache\StaticFileBackend::class,
     'groups' => [
         'pages',
         'all'
index ec56fce..a7b6f88 100644 (file)
@@ -25,6 +25,6 @@ $tmp = [
 if (TYPO3_MODE == 'BE') {
     // Add Web>Info module:
     \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction('web_info',
-        'SFC\\NcStaticfilecache\\Module\\CacheModule', null,
+        \SFC\NcStaticfilecache\Module\CacheModule::class, null,
         'LLL:EXT:nc_staticfilecache/Resources/Private/Language/locallang.xml:module.title');
 }