[TASK] CSC: Do not show pageTS template if it's included by default 62/44762/6
authorMarkus Klein <markus.klein@typo3.org>
Tue, 17 Nov 2015 18:53:09 +0000 (19:53 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 19 Nov 2015 16:28:50 +0000 (17:28 +0100)
If the extension css_styled_content is configured to include the
pageTS by default, there is no need to show the template in the
page resources.

Resolves: #71639
Releases: master
Change-Id: I3816e8030ea01c6239dcdc0f7a178b64989c6633
Reviewed-on: https://review.typo3.org/44762
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Josef Glatz <josef.glatz@typo3.org>
Tested-by: Josef Glatz <josef.glatz@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/css_styled_content/Classes/Hooks/TcaCacheClearing.php [new file with mode: 0644]
typo3/sysext/css_styled_content/Configuration/TCA/Overrides/pages.php
typo3/sysext/css_styled_content/ext_localconf.php
typo3/sysext/fluid_styled_content/Classes/Hooks/TcaCacheClearing.php [new file with mode: 0644]
typo3/sysext/fluid_styled_content/ext_localconf.php

diff --git a/typo3/sysext/css_styled_content/Classes/Hooks/TcaCacheClearing.php b/typo3/sysext/css_styled_content/Classes/Hooks/TcaCacheClearing.php
new file mode 100644 (file)
index 0000000..b7ea4c2
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+namespace TYPO3\CMS\CssStyledContent\Hooks;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Utility to clear the TCA cache
+ */
+class TcaCacheClearing
+{
+    /**
+     * Flush the cache_core cache to remove cached TCA
+     *
+     * @return void
+     */
+    public static function clearTcaCache()
+    {
+        $cacheManager = GeneralUtility::makeInstance(CacheManager::class);
+        $cacheManager->getCache('cache_core')->flush();
+    }
+}
index d7aeda7..739e7fd 100644 (file)
@@ -1,9 +1,18 @@
 <?php
 defined('TYPO3_MODE') or die();
 
-// Add pageTSconfig
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile(
-    'css_styled_content',
-    'Configuration/PageTSconfig/NewContentElementWizard.ts',
-    'CSS-based Content Elements'
+call_user_func(
+    function ($extKey) {
+        $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extKey]);
+
+        if (isset($extConf['loadContentElementWizardTsConfig']) && (int)$extConf['loadContentElementWizardTsConfig'] === 0) {
+            // Add pageTSconfig
+            \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile(
+                $extKey,
+                'Configuration/PageTSconfig/NewContentElementWizard.ts',
+                'CSS-based Content Elements'
+            );
+        }
+    },
+    'css_styled_content'
 );
index 162abb5..4cdbbb6 100644 (file)
@@ -25,7 +25,25 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php'][
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['text'] =
     \TYPO3\CMS\CssStyledContent\Hooks\PageLayoutView\TextPreviewRenderer::class;
 
-if (!isset($extConf['loadContentElementWizardTsConfig']) || (int)$extConf['loadContentElementWizardTsConfig'] === 1) {
-    // Include new content elements to modWizards
-    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:css_styled_content/Configuration/PageTSconfig/NewContentElementWizard.ts">');
+if (TYPO3_MODE === 'BE') {
+    call_user_func(
+        function ($extKey) {
+            // Get the extension configuration
+            $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extKey]);
+
+            if (!isset($extConf['loadContentElementWizardTsConfig']) || (int)$extConf['loadContentElementWizardTsConfig'] === 1) {
+                // Include new content elements to modWizards
+                \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:css_styled_content/Configuration/PageTSconfig/NewContentElementWizard.ts">');
+            }
+
+            $dispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
+            $dispatcher->connect(
+                \TYPO3\CMS\Extensionmanager\Controller\ConfigurationController::class,
+                'afterExtensionConfigurationWrite',
+                \TYPO3\CMS\CssStyledContent\Hooks\TcaCacheClearing::class,
+                'clearTcaCache'
+            );
+        },
+        $_EXTKEY
+    );
 }
diff --git a/typo3/sysext/fluid_styled_content/Classes/Hooks/TcaCacheClearing.php b/typo3/sysext/fluid_styled_content/Classes/Hooks/TcaCacheClearing.php
new file mode 100644 (file)
index 0000000..38aaeff
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+namespace TYPO3\CMS\FluidStyledContent\Hooks;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Utility to clear the TCA cache
+ */
+class TcaCacheClearing
+{
+    /**
+     * Flush the cache_core cache to remove cached TCA
+     *
+     * @return void
+     */
+    public function clearTcaCache()
+    {
+        $cacheManager = GeneralUtility::makeInstance(CacheManager::class);
+        $cacheManager->getCache('cache_core')->flush();
+    }
+}
index 0870d3d..272b8b7 100644 (file)
@@ -17,6 +17,14 @@ if (TYPO3_MODE === 'BE') {
                 // Include new content elements to modWizards
                 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:fluid_styled_content/Configuration/PageTSconfig/NewContentElementWizard.ts">');
             }
+
+            $dispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
+            $dispatcher->connect(
+                \TYPO3\CMS\Extensionmanager\Controller\ConfigurationController::class,
+                'afterExtensionConfigurationWrite',
+                \TYPO3\CMS\FluidStyledContent\Hooks\TcaCacheClearing::class,
+                'clearTcaCache'
+            );
         },
         $_EXTKEY
     );