[BUGFIX] Use single postProcessor layout, otherwise the global layout 19/35219/11
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 10:22:17 +0000 (12:22 +0200)
Change-Id: Ifcd3dfd9986684f95ab5574a190c4c8b215d0908
Resolves: #60995
Releases: master, 6.2
Reviewed-on: http://review.typo3.org/35219
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/form/Classes/PostProcess/PostProcessor.php
typo3/sysext/form/Tests/Unit/PostProcess/PostProcessorTest.php

index 090f43a..1c89c38 100644 (file)
@@ -56,7 +56,6 @@ class PostProcessor {
                $html = '';
                if (is_array($this->typoScript)) {
                        $keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($this->typoScript);
-                       $layoutHandler = $this->typoscriptFactory->setLayoutHandler($this->typoScript);
 
                        foreach ($keys as $key) {
                                if (!(int)$key || strpos($key, '.') !== FALSE) {
@@ -68,6 +67,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 {
@@ -90,4 +96,4 @@ class PostProcessor {
                return $html;
        }
 
-}
+}
\ No newline at end of file
index 34e7d11..f954a38 100644 (file)
@@ -122,4 +122,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());
+       }
+}
\ No newline at end of file