[+TASK] Fluid: Make use of newly introduced Extension Service
authorBastian Waidelich <bastian@typo3.org>
Thu, 9 Jun 2011 11:58:31 +0000 (13:58 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sun, 26 Jun 2011 23:11:13 +0000 (01:11 +0200)
Since r11323b56 most functions of Tx_Extbase_Utility_Extension
are deprecated and have been used to the new
Tx_Extbase_Service_ExtensionService.
This change makes use of the new Service in Widget and Form VH

Change-Id: I07180cc038d6f33652e1994e7054a1f5d19fb266
Related: #13864

typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php
typo3/sysext/fluid/Tests/Unit/Core/Widget/AbstractWidgetViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php

index 4353e46..a713749 100644 (file)
@@ -56,6 +56,11 @@ abstract class Tx_Fluid_Core_Widget_AbstractWidgetViewHelper extends Tx_Fluid_Co
        private $objectManager;
 
        /**
+        * @var Tx_Extbase_Service_ExtensionService
+        */
+       protected $extensionService;
+
+       /**
         * @var Tx_Fluid_Core_Widget_WidgetContext
         */
        private $widgetContext;
@@ -80,6 +85,14 @@ abstract class Tx_Fluid_Core_Widget_AbstractWidgetViewHelper extends Tx_Fluid_Co
        }
 
        /**
+        * @param Tx_Extbase_Service_ExtensionService $extensionService
+        * @return void
+        */
+       public function injectExtensionService(Tx_Extbase_Service_ExtensionService $extensionService) {
+               $this->extensionService = $extensionService;
+       }
+
+       /**
         * Initialize the arguments of the ViewHelper, and call the render() method of the ViewHelper.
         *
         * @param array $renderMethodParameters the parameters of the render() method.
@@ -111,7 +124,7 @@ abstract class Tx_Fluid_Core_Widget_AbstractWidgetViewHelper extends Tx_Fluid_Co
                $pluginName = $this->controllerContext->getRequest()->getPluginName();
                $this->widgetContext->setParentExtensionName($extensionName);
                $this->widgetContext->setParentPluginName($pluginName);
-               $pluginNamespace = Tx_Extbase_Utility_Extension::getPluginNamespace($extensionName, $pluginName);
+               $pluginNamespace = $this->extensionService->getPluginNamespace($extensionName, $pluginName);
                $this->widgetContext->setParentPluginNamespace($pluginNamespace);
 
                $this->widgetContext->setWidgetViewHelperClassName(get_class($this));
index 34e4725..523a56e 100644 (file)
@@ -65,6 +65,11 @@ class Tx_Fluid_ViewHelpers_FormViewHelper extends Tx_Fluid_ViewHelpers_Form_Abst
        protected $requestHashService;
 
        /**
+        * @var Tx_Extbase_Service_ExtensionService
+        */
+       protected $extensionService;
+
+       /**
         * We need the arguments of the formActionUri on requesthash calculation
         * therefore we will store them in here right after calling uriBuilder
         *
@@ -84,6 +89,14 @@ class Tx_Fluid_ViewHelpers_FormViewHelper extends Tx_Fluid_ViewHelpers_Form_Abst
        }
 
        /**
+        * @param Tx_Extbase_Service_ExtensionService $extensionService
+        * @return void
+        */
+       public function injectExtensionService(Tx_Extbase_Service_ExtensionService $extensionService) {
+               $this->extensionService = $extensionService;
+       }
+
+       /**
         * Initialize arguments.
         *
         * @return void
@@ -387,8 +400,11 @@ class Tx_Fluid_ViewHelpers_FormViewHelper extends Tx_Fluid_ViewHelpers_Form_Abst
                } else {
                        $pluginName = $request->getPluginName();
                }
-
-               return Tx_Extbase_Utility_Extension::getPluginNamespace($extensionName, $pluginName);
+               if ($extensionName !== NULL && $pluginName != NULL) {
+                       return $this->extensionService->getPluginNamespace($extensionName, $pluginName);
+               } else {
+                       return '';
+               }
        }
 
        /**
index 952dde0..7921f03 100644 (file)
@@ -58,10 +58,17 @@ class Tx_Fluid_Tests_Unit_Core_Widget_AbstractWidgetViewHelperTest extends Tx_Ex
        protected $request;
 
        /**
+        * @var Tx_Extbase_Service_ExtensionService
+        */
+       protected $mockExtensionService;
+
+       /**
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
        public function setUp() {
                $this->viewHelper = $this->getAccessibleMock('Tx_Fluid_Core_Widget_AbstractWidgetViewHelper', array('validateArguments', 'initialize', 'callRenderMethod', 'getWidgetConfiguration', 'getRenderingContext'));
+               $this->mockExtensionService = $this->getMock('Tx_Extbase_Service_ExtensionService');
+               $this->viewHelper->injectExtensionService($this->mockExtensionService);
 
                $this->ajaxWidgetContextHolder = $this->getMock('Tx_Fluid_Core_Widget_AjaxWidgetContextHolder');
                $this->viewHelper->injectAjaxWidgetContextHolder($this->ajaxWidgetContextHolder);
@@ -77,7 +84,6 @@ class Tx_Fluid_Tests_Unit_Core_Widget_AbstractWidgetViewHelperTest extends Tx_Ex
                $this->controllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext', array(), array(), '', FALSE);
                $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
                $this->viewHelper->_set('controllerContext', $this->controllerContext);
-
        }
 
        /**
index a9fd64f..c7d6bb9 100644 (file)
@@ -28,6 +28,17 @@ require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
 class Tx_Fluid_Tests_Unit_ViewHelpers_FormViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
+
+       /**
+        * @var Tx_Extbase_Service_ExtensionService
+        */
+       protected $mockExtensionService;
+
+       public function setUp() {
+               parent::setUp();
+               $this->mockExtensionService = $this->getMock('Tx_Extbase_Service_ExtensionService');
+       }
+
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
@@ -206,6 +217,8 @@ class Tx_Fluid_Tests_Unit_ViewHelpers_FormViewHelperTest extends Tx_Fluid_ViewHe
                $expectedPrefix = 'tx_someextension_someplugin';
 
                $viewHelper = $this->getAccessibleMock('Tx_Fluid_ViewHelpers_FormViewHelper', array('renderChildren', 'renderHiddenIdentityField', 'renderHiddenReferrerFields', 'renderRequestHashField', 'addFormFieldNamesToViewHelperVariableContainer', 'removeFormFieldNamesFromViewHelperVariableContainer'), array(), '', FALSE);
+               $this->mockExtensionService->expects($this->once())->method('getPluginNamespace')->with('SomeExtension', 'SomePlugin')->will($this->returnValue('tx_someextension_someplugin'));
+               $viewHelper->injectExtensionService($this->mockExtensionService);
                $this->injectDependenciesIntoViewHelper($viewHelper);
 
                $viewHelper->setArguments(new Tx_Fluid_Core_ViewHelper_Arguments(array('extensionName' => 'SomeExtension', 'pluginName' => 'SomePlugin')));