[BUGFIX] Add stdWrap support for Partial- and layoutRootPaths 84/41584/9
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 17 Jul 2015 17:06:23 +0000 (19:06 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 18 Jul 2015 14:21:43 +0000 (16:21 +0200)
The single occurrences layoutRootPath and partialRootPath have
stdWrap support, but not the collection entries of
layoutRootPaths and partialRootPaths. This is added now.

Change-Id: I59d4967ce67b48b53e9bf1052d703c974f1472ca
Resolves: #63380
Releases: master, 6.2
Reviewed-on: http://review.typo3.org/41584
Reviewed-by: Oliver Eglseder <oliver.eglseder@in2code.de>
Tested-by: Oliver Eglseder <oliver.eglseder@in2code.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php
typo3/sysext/frontend/Tests/Unit/ContentObject/FluidTemplateContentObjectTest.php

index bc0a7c2..4f96672 100644 (file)
@@ -14,7 +14,6 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Extbase\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Service\TypoScriptService;
 use TYPO3\CMS\Fluid\View\StandaloneView;
@@ -108,7 +107,11 @@ class FluidTemplateContentObject extends AbstractContentObject {
                if (!empty($conf['templateName']) && !empty($conf['templateRootPaths.']) && is_array($conf['templateRootPaths.'])) {
                        $templateRootPaths = array();
                        foreach ($conf['templateRootPaths.'] as $key => $path) {
-                               $templateRootPaths[$key] = GeneralUtility::getFileAbsFileName($path);
+                               if (strpos($key, '.') === FALSE) {
+                                               $templateRootPaths[$key] = isset($conf['templateRootPaths.'][$key . '.']) ?
+                                                       GeneralUtility::getFileAbsFileName($this->cObj->stdWrap($conf['templateRootPaths.'][$key], $conf['templateRootPaths.'][$key . '.'])) :
+                                                       GeneralUtility::getFileAbsFileName($path);
+                               }
                        }
                        $this->view->setTemplateRootPaths($templateRootPaths);
                        $templateName = isset($conf['templateName.']) ? $this->cObj->stdWrap($conf['templateName'], $conf['templateName.']) : $conf['templateName'];
@@ -144,7 +147,12 @@ class FluidTemplateContentObject extends AbstractContentObject {
                }
                if (isset($conf['layoutRootPaths.'])) {
                        foreach ($conf['layoutRootPaths.'] as $key => $path) {
-                               $layoutPaths[$key] = GeneralUtility::getFileAbsFileName($path);
+                               if (strpos($key, '.') === FALSE) {
+                                       $layoutPaths[$key] = isset($conf['layoutRootPaths.'][$key . '.']) ?
+                                               GeneralUtility::getFileAbsFileName($this->cObj->stdWrap($conf['layoutRootPaths.'][$key], $conf['layoutRootPaths.'][$key . '.'])) :
+                                               GeneralUtility::getFileAbsFileName($path);
+                               }
+
                        }
                }
                if (!empty($layoutPaths)) {
@@ -168,7 +176,11 @@ class FluidTemplateContentObject extends AbstractContentObject {
                }
                if (isset($conf['partialRootPaths.'])) {
                        foreach ($conf['partialRootPaths.'] as $key => $path) {
-                               $partialPaths[$key] = GeneralUtility::getFileAbsFileName($path);
+                               if (strpos($key, '.') === FALSE) {
+                                       $partialPaths[$key] = isset($conf['partialRootPaths.'][$key . '.']) ?
+                                               GeneralUtility::getFileAbsFileName($this->cObj->stdWrap($conf['partialRootPaths.'][$key], $conf['partialRootPaths.'][$key . '.'])) :
+                                               GeneralUtility::getFileAbsFileName($path);
+                               }
                        }
                }
                if (!empty($partialPaths)) {
index 2126063..a3d0850 100644 (file)
@@ -138,6 +138,36 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        /**
         * @test
         */
+       public function renderCallsStandardWrapForGivenTemplateRootPathsWithStandardWrap() {
+               $this->addMockViewToSubject();
+               $this->contentObjectRenderer
+                       ->expects($this->at(0))
+                       ->method('stdWrap')
+                       ->with('FILE', array('file' => 'dummyPath5/'));
+               $this->contentObjectRenderer
+                       ->expects($this->at(1))
+                       ->method('stdWrap')
+                       ->with('FILE', array('file' => 'dummyPath25/'));
+               $this->subject->render(array(
+                               'templateName' => 'foobar',
+                               'templateRootPaths.' => array(
+                                       10 => 'FILE',
+                                       '10.' => array(
+                                               'file' => 'dummyPath5/',
+                                       ),
+                                       15 => 'dummyPath6/',
+                                       25 => 'FILE',
+                                       '25.' => array(
+                                               'file' => 'dummyPath25/',
+                                       ),
+                               )
+                       )
+               );
+       }
+
+       /**
+        * @test
+        */
        public function renderSetsTemplateFileInView() {
                $this->addMockViewToSubject();
                /** @var $templateService \PHPUnit_Framework_MockObject_MockObject */
@@ -260,6 +290,28 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        /**
         * @test
         */
+       public function layoutRootPathsHasStdWrapSupport() {
+               $this->addMockViewToSubject();
+               $this->contentObjectRenderer
+                       ->expects($this->at(0))
+                       ->method('stdWrap')
+                       ->with('FILE', array('file' => 'foo/bar.html'));
+               $this->subject->render(
+                       array(
+                               'layoutRootPaths.' => array(
+                                       10 => 'FILE',
+                                       '10.' => array(
+                                               'file' => 'foo/bar.html',
+                                       ),
+                                       20 => 'foo/bar2.html',
+                               )
+                       )
+               );
+       }
+
+       /**
+        * @test
+        */
        public function fallbacksForLayoutRootPathAreSet() {
                $this->addMockViewToSubject();
                $this->standaloneView
@@ -296,6 +348,28 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        /**
         * @test
         */
+       public function partialRootPathsHasStdWrapSupport() {
+               $this->addMockViewToSubject();
+               $this->contentObjectRenderer
+                       ->expects($this->at(0))
+                       ->method('stdWrap')
+                       ->with('FILE', array('file' => 'foo/bar.html'));
+               $this->subject->render(
+                       array(
+                               'partialRootPaths.' => array(
+                                       10 => 'FILE',
+                                       '10.' => array(
+                                               'file' => 'foo/bar.html',
+                                       ),
+                                       20 => 'foo/bar2.html',
+                               )
+                       )
+               );
+       }
+
+       /**
+        * @test
+        */
        public function renderCallsStandardWrapForPartialRootPath() {
                $this->addMockViewToSubject();
                $this->contentObjectRenderer