From: Christian Kuhn Date: Mon, 22 Oct 2012 15:38:07 +0000 (+0200) Subject: [BUGFIX] Remove singleton for EXT:form Localization X-Git-Tag: TYPO3_6-0-0rc1~111 X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/commitdiff_plain/f66d1636041c15f51af5124cb0b2b00e5f8fd0e3 [BUGFIX] Remove singleton for EXT:form Localization \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 --- diff --git a/typo3/sysext/form/Classes/Controller/FormController.php b/typo3/sysext/form/Classes/Controller/FormController.php index 409d28515f3..d4acd618c8a 100644 --- a/typo3/sysext/form/Classes/Controller/FormController.php +++ b/typo3/sysext/form/Classes/Controller/FormController.php @@ -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); diff --git a/typo3/sysext/form/Classes/Localization.php b/typo3/sysext/form/Classes/Localization.php index d3087751734..d851654bb63 100644 --- a/typo3/sysext/form/Classes/Localization.php +++ b/typo3/sysext/form/Classes/Localization.php @@ -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; }