[BUGFIX] Fix usage of deprecated methods in FluidTemplateContentObject 40/34340/3
authorMarkus Klein <klein.t3@reelworx.at>
Wed, 19 Nov 2014 11:34:18 +0000 (12:34 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Wed, 19 Nov 2014 16:44:24 +0000 (17:44 +0100)
StandaloneView now supports fallback paths.
The old setters are deprecated.
Use the plural method names.

Resolves: #63066
Releases: master
Change-Id: I6281c93047672e252735d99b8c76e5700efc2fed
Reviewed-on: http://review.typo3.org/34340
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php
typo3/sysext/frontend/Tests/Unit/ContentObject/FluidTemplateContentObjectTest.php

index cefc1b8..621a08d 100644 (file)
@@ -13,6 +13,9 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Service\TypoScriptService;
+use TYPO3\CMS\Fluid\View\StandaloneView;
 
 /**
  * Contains TEMPLATE class object.
@@ -26,12 +29,14 @@ namespace TYPO3\CMS\Frontend\ContentObject;
 class FluidTemplateContentObject extends AbstractContentObject {
 
        /**
-        * @var \TYPO3\CMS\Fluid\View\StandaloneView
+        * @var StandaloneView
         */
        protected $view = NULL;
 
        /**
         * Constructor
+        *
+        * @param ContentObjectRenderer $contentObjectRenderer
         */
        public function __construct(ContentObjectRenderer $contentObjectRenderer) {
                parent::__construct($contentObjectRenderer);
@@ -78,7 +83,7 @@ class FluidTemplateContentObject extends AbstractContentObject {
                $this->setExtbaseVariables($conf);
                $this->assignSettings($conf);
                $this->assignContentObjectVariables($conf);
-               $this->assignContentObjectDataAndCurrent($conf);
+               $this->assignContentObjectDataAndCurrent();
 
                $content = $this->renderFluidView();
                $content = $this->applyStandardWrapToRenderedContent($content, $conf);
@@ -97,7 +102,7 @@ class FluidTemplateContentObject extends AbstractContentObject {
         * @return void
         */
        protected function initializeStandaloneViewInstance() {
-               $this->view = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\View\StandaloneView::class);
+               $this->view = GeneralUtility::makeInstance(StandaloneView::class);
        }
 
        /**
@@ -131,8 +136,8 @@ class FluidTemplateContentObject extends AbstractContentObject {
                // Override the default layout path via typoscript
                $layoutRootPath = isset($conf['layoutRootPath.']) ? $this->cObj->stdWrap($conf['layoutRootPath'], $conf['layoutRootPath.']) : $conf['layoutRootPath'];
                if ($layoutRootPath) {
-                       $layoutRootPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($layoutRootPath);
-                       $this->view->setLayoutRootPath($layoutRootPath);
+                       $layoutRootPath = GeneralUtility::getFileAbsFileName($layoutRootPath);
+                       $this->view->setLayoutRootPaths(array($layoutRootPath));
                }
        }
 
@@ -145,8 +150,8 @@ class FluidTemplateContentObject extends AbstractContentObject {
        protected function setPartialRootPath(array $conf) {
                $partialRootPath = isset($conf['partialRootPath.']) ? $this->cObj->stdWrap($conf['partialRootPath'], $conf['partialRootPath.']) : $conf['partialRootPath'];
                if ($partialRootPath) {
-                       $partialRootPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($partialRootPath);
-                       $this->view->setPartialRootPath($partialRootPath);
+                       $partialRootPath = GeneralUtility::getFileAbsFileName($partialRootPath);
+                       $this->view->setPartialRootPaths(array($partialRootPath));
                }
        }
 
@@ -227,8 +232,8 @@ class FluidTemplateContentObject extends AbstractContentObject {
         */
        protected function assignSettings(array $conf) {
                if (array_key_exists('settings.', $conf)) {
-                       /** @var $typoScriptService \TYPO3\CMS\Extbase\Service\TypoScriptService */
-                       $typoScriptService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Service\TypoScriptService::class);
+                       /** @var $typoScriptService TypoScriptService */
+                       $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
                        $settings = $typoScriptService->convertTypoScriptArrayToPlainArray($conf['settings.']);
                        $this->view->assign('settings', $settings);
                }
@@ -237,10 +242,9 @@ class FluidTemplateContentObject extends AbstractContentObject {
        /**
         * Assign content object renderer data and current to view
         *
-        * @param array $conf Configuration
         * @return void
         */
-       protected function assignContentObjectDataAndCurrent(array $conf) {
+       protected function assignContentObjectDataAndCurrent() {
                $this->view->assign('data', $this->cObj->data);
                $this->view->assign('current', $this->cObj->data[$this->cObj->currentValKey]);
        }
index f55cd5c..6f26546 100644 (file)
@@ -13,6 +13,9 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Service\TypoScriptService;
+
 /**
  * Testcase
  *
@@ -49,7 +52,7 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * Set up
         */
        public function setUp() {
-               $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
+               $this->singletonInstances = GeneralUtility::getSingletonInstances();
                $this->contentObjectRenderer = $this->getMock(
                        'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'
                );
@@ -68,7 +71,7 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * Tear down
         */
        public function tearDown() {
-               \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
+               GeneralUtility::resetSingletonInstances($this->singletonInstances);
                parent::tearDown();
        }
 
@@ -95,7 +98,7 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        /**
         * @test
         */
-       public function renderCallsinitializeStandaloneViewInstance() {
+       public function renderCallsInitializeStandaloneViewInstance() {
                $this->addMockViewToFixture();
                $this->fixture
                        ->expects($this->once())
@@ -180,8 +183,8 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                $this->addMockViewToFixture();
                $this->standaloneView
                        ->expects($this->once())
-                       ->method('setLayoutRootPath')
-                       ->with(PATH_site . 'foo/bar.html');
+                       ->method('setLayoutRootPaths')
+                       ->with(array(PATH_site . 'foo/bar.html'));
                $this->fixture->render(array('layoutRootPath' => 'foo/bar.html'));
        }
 
@@ -204,8 +207,8 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                $this->addMockViewToFixture();
                $this->standaloneView
                        ->expects($this->once())
-                       ->method('setPartialRootPath')
-                       ->with(PATH_site . 'foo/bar.html');
+                       ->method('setPartialRootPaths')
+                       ->with(array(PATH_site . 'foo/bar.html'));
                $this->fixture->render(array('partialRootPath' => 'foo/bar.html'));
        }
 
@@ -415,13 +418,14 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                        ),
                );
 
+               /** @var TypoScriptService|\PHPUnit_Framework_MockObject_MockObject $typoScriptServiceMock */
                $typoScriptServiceMock = $this->getMock('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService');
                $typoScriptServiceMock
                        ->expects($this->once())
                        ->method('convertTypoScriptArrayToPlainArray')
                        ->with($configuration['settings.'])
                        ->will($this->returnValue($expectedSettingsToBeSet));
-               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService', $typoScriptServiceMock);
+               GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService', $typoScriptServiceMock);
 
                $this->standaloneView
                        ->expects($this->at(1))