[BUGFIX] Use single postProcessor layout, otherwise the global layout 26/42926/4
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Sat, 29 Aug 2015 14:57:47 +0000 (16:57 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Sun, 30 Aug 2015 14:10:38 +0000 (16:10 +0200)
Resolves: #60995
Releases: master, 6.2
Change-Id: Ifcd3dfd9986684f95ab5574a190c4c8b215d0908
Reviewed-on: http://review.typo3.org/42926
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/form/Classes/PostProcess/PostProcessor.php
typo3/sysext/form/Tests/Unit/PostProcess/PostProcessorTest.php

index b4503eb..ba2dce9 100644 (file)
@@ -54,8 +54,7 @@ class PostProcessor {
        public function process() {
                $html = '';
                if (is_array($this->typoScript)) {
-                       $keys = $this->sortTypoScriptKeyList();
-                       $layoutHandler = $this->typoscriptFactory->setLayoutHandler($this->typoScript);
+                       $keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($this->typoScript);
 
                        foreach ($keys as $key) {
                                if (!(int)$key || strpos($key, '.') !== FALSE) {
@@ -67,6 +66,13 @@ class PostProcessor {
                                if (isset($this->typoScript[$key . '.'])) {
                                        $processorArguments = $this->typoScript[$key . '.'];
                                }
+
+                               if (isset($processorArguments['layout.'])) {
+                                       $layoutHandler = $this->typoscriptFactory->setLayoutHandler($processorArguments);
+                               } else {
+                                       $layoutHandler = $this->typoscriptFactory->setLayoutHandler($this->typoScript);
+                               }
+
                                if (class_exists($processorName, TRUE)) {
                                        $className = $processorName;
                                } else {
@@ -94,6 +100,7 @@ class PostProcessor {
         * (makes unit testing possible)
         *
         * @return array
+        * @deprecated in TYPO3 CMS 7, does not trigger deprecation log in 6.2
         */
        public function sortTypoScriptKeyList() {
                return \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($this->typoScript);
index 5920a65..cbcaaf8 100644 (file)
@@ -118,4 +118,51 @@ class PostProcessorTest extends UnitTestCase {
 
                $this->assertEquals('', $subject->process());
        }
+
+       /**
+        * @test
+        */
+       public function processUsesGlobalLayoutIfNoneIsSet() {
+               $processorConfig = array(
+                       'recipientEmail' => 'your@email.com',
+                       'senderEmail' => 'your@email.com',
+               );
+               $typoScript = array(
+                       'layout.' => array(
+                                       'label' => '<div class="global"><labelvalue /></div>',
+                       ),
+                       '1' => 'foo', // something senseless on purpose, otherwise dependencies need to be resolved, that come in by static call -> ugly
+                       '1.' => $processorConfig
+               );
+
+               $subject = new PostProcessor($this->formProphecy->reveal(), $typoScript);
+               $this->typoScriptFactoryProphecy->setLayoutHandler($typoScript)->willReturn($this->typoScriptLayoutProphecy->reveal());
+
+               $this->assertEquals('', $subject->process());
+       }
+
+       /**
+        * @test
+        */
+       public function processUsesLocalLayoutIfSet() {
+               $processorConfig = array(
+                       'layout.' => array(
+                                       'label' => '<div class="local"><labelvalue /></div>',
+                       ),
+                       'recipientEmail' => 'your@email.com',
+                       'senderEmail' => 'your@email.com',
+               );
+               $typoScript = array(
+                       'layout.' => array(
+                                       'label' => '<div class="global"><labelvalue /></div>',
+                       ),
+                       '1' => 'foo',
+                       '1.' => $processorConfig
+               );
+
+               $subject = new PostProcessor($this->formProphecy->reveal(), $typoScript);
+               $this->typoScriptFactoryProphecy->setLayoutHandler($processorConfig)->willReturn($this->typoScriptLayoutProphecy->reveal());
+
+               $this->assertEquals('', $subject->process());
+       }
 }