[BUGFIX] Remove singleton for EXT:form Localization
authorChristian Kuhn <lolli@schwarzbu.ch>
Mon, 22 Oct 2012 15:38:07 +0000 (17:38 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 22 Oct 2012 16:11:59 +0000 (18:11 +0200)
\TYPO3\CMS\Form\Localization is a singleton class with constructor
parameters. This is an antipattern and broken by design. As an effect
it leads to warnings in unit tests and makes the class unusable
with multiple files.

The patch removes the implementation of the singletonInterface, but
sets the default localization file as default parameter to keep
backwards compatibility.

Change-Id: I3ed5c77c5c3a653c8d5e7259baa64a41c8c20859
Resolves: #42280
Releases: 6.0
Reviewed-on: http://review.typo3.org/15886
Reviewed-by: Steffen Ritter
Reviewed-by: Wouter Wolters
Reviewed-by: Nicole Cordes
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/form/Classes/Controller/FormController.php
typo3/sysext/form/Classes/Localization.php

index 409d285..d4acd61 100644 (file)
@@ -68,7 +68,6 @@ class FormController {
         * @return void
         */
        public function initialize(array $typoscript) {
-               \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Localization', 'LLL:EXT:form/Resources/Private/Language/locallang_controller.xml');
                $this->typoscriptFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Domain\\Factory\\TypoScriptFactory');
                $this->localizationHandler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Localization');
                $this->requestHandler = $this->typoscriptFactory->setRequestHandler($typoscript);
index d308775..d851654 100644 (file)
@@ -30,7 +30,7 @@ namespace TYPO3\CMS\Form;
  * @package TYPO3
  * @subpackage form
  */
-class Localization implements \TYPO3\CMS\Core\SingletonInterface {
+class Localization {
 
        /**
         * File reference to the local language file
@@ -44,7 +44,7 @@ class Localization implements \TYPO3\CMS\Core\SingletonInterface {
         *
         * @param string $localLanguageFile File reference to the local language file
         */
-       public function __construct($localLanguageFile) {
+       public function __construct($localLanguageFile = 'LLL:EXT:form/Resources/Private/Language/locallang_controller.xml') {
                $this->localLanguageFile = (string) $localLanguageFile;
        }