[BUGFIX] Move option formatToPageTypeMapping 26/43926/7
authorChristian Futterlieb <christian@futterlieb.ch>
Fri, 9 Oct 2015 08:50:54 +0000 (10:50 +0200)
committerBenni Mack <benni@typo3.org>
Sat, 9 Dec 2017 22:51:28 +0000 (23:51 +0100)
Move the option formatToPageTypeMapping from
plugin.tx_myextension.settings.view.formatToPageTypeMapping to
plugin.tx_myextension.view.formatToPageTypeMapping

and deprecate the usage of the wrong location.

Resolves: #70526
Releases: master
Change-Id: I660aa41097e6cdba5e8fb90591a67a0b83ee90f2
Reviewed-on: https://review.typo3.org/43926
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Documentation/Changelog/master/Deprecation-70526-LocationOfFormatToPageTypeMappingOption.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Service/ExtensionService.php
typo3/sysext/extbase/Tests/Unit/Mvc/Web/Routing/UriBuilderTest.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-70526-LocationOfFormatToPageTypeMappingOption.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-70526-LocationOfFormatToPageTypeMappingOption.rst
new file mode 100644 (file)
index 0000000..b438216
--- /dev/null
@@ -0,0 +1,42 @@
+.. include:: ../../Includes.txt
+
+================================================================
+Deprecation: #70526 - Location of formatToPageTypeMapping option
+================================================================
+
+See :issue:`70526`
+
+Description
+===========
+
+Since its introduction, the option :ts:`formatToPageTypeMapping` had to be configured in :ts:`settings.view.formatToPageTypeMapping` instead of :ts:`view.formatToPageTypeMapping`. This has been marked as deprecated.
+
+
+Impact
+======
+
+Defining :ts:`settings.view.formatToPageTypeMapping` will trigger a deprecation log entry.
+
+
+Affected Installations
+======================
+
+Installations containing plugins that define :ts:`settings.view.formatToPageTypeMapping` instead of :ts:`view.formatToPageTypeMapping`.
+
+
+Migration
+=========
+
+Move
+
+.. code-block:: typoscript
+
+    plugin.tx_myextension.settings.view.formatToPageTypeMapping
+
+to
+
+.. code-block:: typoscript
+
+    plugin.tx_myextension.view.formatToPageTypeMapping
+
+.. index:: Frontend, TypoScript, NotScanned
index 888ea3c..d076044 100644 (file)
@@ -16,7 +16,9 @@ namespace TYPO3\CMS\Extbase\Service;
 
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
 
 /**
  * Service for determining basic extension params
@@ -32,7 +34,7 @@ class ExtensionService implements \TYPO3\CMS\Core\SingletonInterface
     protected $objectManager;
 
     /**
-     * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
+     * @var ConfigurationManagerInterface
      */
     protected $configurationManager;
 
@@ -51,9 +53,9 @@ class ExtensionService implements \TYPO3\CMS\Core\SingletonInterface
     }
 
     /**
-     * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
+     * @param ConfigurationManagerInterface $configurationManager
      */
-    public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
+    public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
     {
         $this->configurationManager = $configurationManager;
     }
@@ -71,7 +73,7 @@ class ExtensionService implements \TYPO3\CMS\Core\SingletonInterface
     {
         $pluginSignature = strtolower($extensionName . '_' . $pluginName);
         $defaultPluginNamespace = 'tx_' . $pluginSignature;
-        $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
+        $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
         if (!isset($frameworkConfiguration['view']['pluginNamespace']) || empty($frameworkConfiguration['view']['pluginNamespace'])) {
             return $defaultPluginNamespace;
         }
@@ -93,7 +95,7 @@ class ExtensionService implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function getPluginNameByAction($extensionName, $controllerName, $actionName)
     {
-        $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
+        $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
         // check, whether the current plugin is configured to handle the action
         if ($extensionName === $frameworkConfiguration['extensionName']) {
             if (isset($frameworkConfiguration['controllerConfiguration'][$controllerName]) && in_array($actionName, $frameworkConfiguration['controllerConfiguration'][$controllerName]['actions'])) {
@@ -132,7 +134,7 @@ class ExtensionService implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function isActionCacheable($extensionName, $pluginName, $controllerName, $actionName)
     {
-        $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
+        $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
         if (isset($frameworkConfiguration['controllerConfiguration'][$controllerName]) && is_array($frameworkConfiguration['controllerConfiguration'][$controllerName]) && is_array($frameworkConfiguration['controllerConfiguration'][$controllerName]['nonCacheableActions']) && in_array($actionName, $frameworkConfiguration['controllerConfiguration'][$controllerName]['nonCacheableActions'])) {
             return false;
         }
@@ -153,7 +155,7 @@ class ExtensionService implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function getTargetPidByPlugin($extensionName, $pluginName)
     {
-        $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
+        $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName);
         if (!isset($frameworkConfiguration['view']['defaultPid']) || empty($frameworkConfiguration['view']['defaultPid'])) {
             return null;
         }
@@ -231,7 +233,17 @@ class ExtensionService implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function getTargetPageTypeByFormat($extensionName, $format)
     {
-        $settings = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, $extensionName);
-        return $settings['view']['formatToPageTypeMapping'][$format] ?? 0;
+        // Legacy location
+        $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, $extensionName);
+        if (isset($settings['view']['formatToPageTypeMapping']) && is_array($settings['view']['formatToPageTypeMapping'])) {
+            trigger_error('Extension "' . $extensionName . '": Defining settings.view.formatToPageTypeMapping will be removed in TYPO3 10. Move definition to view.formatToPageTypeMapping.');
+            $formatToPageTypeMapping = $settings['view']['formatToPageTypeMapping'];
+        }
+        // Default behaviour
+        $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName);
+        if (isset($settings['view']['formatToPageTypeMapping']) && is_array($settings['view']['formatToPageTypeMapping'])) {
+            ArrayUtility::mergeRecursiveWithOverrule($formatToPageTypeMapping, $settings['view']['formatToPageTypeMapping']);
+        }
+        return $formatToPageTypeMapping[$format] ?? 0;
     }
 }
index 13c8ee4..914a719 100644 (file)
@@ -667,7 +667,7 @@ class UriBuilderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
 
         $mockConfigurationManager = $this->createMock(ConfigurationManager::class);
         $mockConfigurationManager->expects($this->any())->method('getConfiguration')
-            ->will($this->returnValue(['view' => ['formatToPageTypeMapping' => ['txt' => 2]]]));
+            ->will($this->returnValue(['formatToPageTypeMapping' => ['txt' => 2]]));
         $this->uriBuilder->_set('configurationManager', $mockConfigurationManager);
 
         $this->mockExtensionService->expects($this->any())->method('getTargetPageTypeByFormat')
@@ -711,7 +711,7 @@ class UriBuilderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
 
         $mockConfigurationManager = $this->createMock(ConfigurationManager::class);
         $mockConfigurationManager->expects($this->any())->method('getConfiguration')
-            ->will($this->returnValue([['view' => ['formatToPageTypeMapping' => ['pdf' => 2]]]]));
+            ->will($this->returnValue(['formatToPageTypeMapping' => ['pdf' => 2]]));
         $this->uriBuilder->_set('configurationManager', $mockConfigurationManager);
 
         $this->mockExtensionService->expects($this->any())->method('getTargetPageTypeByFormat')