[TASK] Replace ObjectManager create with get 74/18174/3
authorMarc Bastian Heinrichs <typo3@mbh-software.de>
Sun, 10 Feb 2013 10:13:11 +0000 (11:13 +0100)
committerAndreas Wolf <andreas.wolf@typo3.org>
Sun, 10 Feb 2013 11:24:44 +0000 (12:24 +0100)
Since Extbase ObjectManager::create is deprecated replace all
usages of the create method with get.

Change-Id: If6658a7620303ccdb88394f31a1b5685a18ecbca
Resolves: #45333
Releases: 6.1
Reviewed-on: https://review.typo3.org/18174
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Andreas Wolf
Tested-by: Andreas Wolf
21 files changed:
typo3/sysext/about/Classes/Domain/Repository/ExtensionRepository.php
typo3/sysext/belog/Classes/Controller/AbstractController.php
typo3/sysext/belog/Classes/Domain/Repository/HistoryEntryRepository.php
typo3/sysext/belog/Classes/Domain/Repository/LogEntryRepository.php
typo3/sysext/belog/Classes/Domain/Repository/WorkspaceRepository.php
typo3/sysext/belog/Tests/Unit/Domain/Repository/HistoryEntryRepositoryTest.php
typo3/sysext/belog/Tests/Unit/Domain/Repository/LogEntryRepositoryTest.php
typo3/sysext/belog/Tests/Unit/Domain/Repository/WorkspaceRepositoryTest.php
typo3/sysext/beuser/Classes/Service/ModuleDataStorageService.php
typo3/sysext/extensionmanager/Classes/Controller/UpdateScriptController.php
typo3/sysext/extensionmanager/Classes/Domain/Repository/ExtensionRepository.php
typo3/sysext/extensionmanager/Classes/Domain/Repository/RepositoryRepository.php
typo3/sysext/extensionmanager/Classes/Utility/ConfigurationUtility.php
typo3/sysext/extensionmanager/Classes/Utility/DependencyUtility.php
typo3/sysext/extensionmanager/Classes/ViewHelpers/UpdateScriptViewHelper.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/ConfigurationUtilityTest.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/DependencyUtilityTest.php
typo3/sysext/lang/Classes/Controller/LanguageController.php
typo3/sysext/lang/Classes/Domain/Repository/ExtensionRepository.php
typo3/sysext/lang/Classes/Domain/Repository/LanguageRepository.php
typo3/sysext/sys_note/Classes/Domain/Repository/SysNoteRepository.php

index 85b7c7c..9c22c83 100644 (file)
@@ -56,7 +56,7 @@ class ExtensionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
                                $emconfPath = PATH_site . $extension['siteRelPath'] . 'ext_emconf.php';
                                if (file_exists($emconfPath)) {
                                        include $emconfPath;
-                                       $extension = $this->objectManager->create('TYPO3\\CMS\\About\\Domain\\Model\\Extension');
+                                       $extension = $this->objectManager->get('TYPO3\\CMS\\About\\Domain\\Model\\Extension');
                                        $extension->setKey($extensionKey);
                                        $extension->setTitle($EM_CONF['']['title']);
                                        $extension->setAuthor($EM_CONF['']['author']);
index 78e21f8..05ce382 100644 (file)
@@ -127,7 +127,7 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
                if ($constraint === NULL) {
                        $constraint = $this->getConstraintFromBeUserData();
                        if ($constraint === NULL) {
-                               $constraint = $this->objectManager->create('TYPO3\\CMS\\Belog\\Domain\\Model\\Constraint');
+                               $constraint = $this->objectManager->get('TYPO3\\CMS\\Belog\\Domain\\Model\\Constraint');
                        }
                } else {
                        $this->persistConstraintInBeUserData($constraint);
index 10846b4..4178bba 100644 (file)
@@ -40,7 +40,7 @@ class HistoryEntryRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
         */
        public function initializeObject() {
                /** @var $querySettings \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface */
-               $querySettings = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
+               $querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
                $querySettings->setRespectStoragePage(FALSE);
                $this->setDefaultQuerySettings($querySettings);
        }
index e9e2cf1..fc48627 100644 (file)
@@ -47,7 +47,7 @@ class LogEntryRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
        public function initializeObject() {
                $this->beUserList = \TYPO3\CMS\Backend\Utility\BackendUtility::getUserNames();
                /** @var $defaultQuerySettings \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface */
-               $defaultQuerySettings = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
+               $defaultQuerySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
                $defaultQuerySettings->setRespectStoragePage(FALSE);
                $this->setDefaultQuerySettings($defaultQuerySettings);
        }
index 577d9b9..e693184 100644 (file)
@@ -42,7 +42,7 @@ class WorkspaceRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
         */
        public function initializeObject() {
                /** @var $querySettings \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface */
-               $querySettings = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
+               $querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
                $querySettings->setRespectStoragePage(FALSE);
                $this->setDefaultQuerySettings($querySettings);
        }
index 35f5baf..4c1dc9f 100644 (file)
@@ -38,7 +38,7 @@ class HistoryEntryRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestC
        public function setUp() {
                $this->querySettings = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
                $this->objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
-               $this->objectManager->expects($this->any())->method('create')->with('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface')->will($this->returnValue($this->querySettings));
+               $this->objectManager->expects($this->any())->method('get')->with('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface')->will($this->returnValue($this->querySettings));
        }
 
        public function tearDown() {
index ca6c1f8..87bab25 100644 (file)
@@ -38,7 +38,7 @@ class LogEntryRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase
        public function setUp() {
                $this->querySettings = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
                $this->objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
-               $this->objectManager->expects($this->any())->method('create')->with('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface')->will($this->returnValue($this->querySettings));
+               $this->objectManager->expects($this->any())->method('get')->with('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface')->will($this->returnValue($this->querySettings));
        }
 
        public function tearDown() {
index dd07542..fe63397 100644 (file)
@@ -38,7 +38,7 @@ class WorkspaceRepositoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase
        public function setUp() {
                $this->querySettings = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
                $this->objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
-               $this->objectManager->expects($this->any())->method('create')->with('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface')->will($this->returnValue($this->querySettings));
+               $this->objectManager->expects($this->any())->method('get')->with('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface')->will($this->returnValue($this->querySettings));
        }
 
        public function tearDown() {
index 8d10329..423a984 100644 (file)
@@ -53,7 +53,7 @@ class ModuleDataStorageService implements \TYPO3\CMS\Core\SingletonInterface {
        public function loadModuleData() {
                $moduleData = $GLOBALS['BE_USER']->getModuleData(self::KEY);
                if (empty($moduleData) || !$moduleData) {
-                       $moduleData = $this->objectManager->create('TYPO3\\CMS\\Beuser\\Domain\\Model\\ModuleData');
+                       $moduleData = $this->objectManager->get('TYPO3\\CMS\\Beuser\\Domain\\Model\\ModuleData');
                } else {
                        $moduleData = @unserialize($moduleData);
                }
index df2af69..d8a7ee5 100644 (file)
@@ -45,7 +45,7 @@ class UpdateScriptController extends \TYPO3\CMS\Extensionmanager\Controller\Abst
                \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Request for update script', 'extensionmanager', 0, $extensionKey);
 
                /** @var $updateScriptUtility \TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility */
-               $updateScriptUtility = $this->objectManager->create('TYPO3\\CMS\\Extensionmanager\\Utility\\UpdateScriptUtility');
+               $updateScriptUtility = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\UpdateScriptUtility');
                $updateScriptResult = $updateScriptUtility->executeUpdateIfNeeded($extensionKey);
                $this->view
                        ->assign('updateScriptResult', $updateScriptResult)
index 18ac89f..416a960 100644 (file)
@@ -57,7 +57,7 @@ class ExtensionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
         */
        public function initializeObject() {
                /** @var $defaultQuerySettings \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface */
-               $defaultQuerySettings = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
+               $defaultQuerySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
                $defaultQuerySettings->setRespectStoragePage(FALSE);
                $this->setDefaultQuerySettings($defaultQuerySettings);
                $this->databaseConnection = $GLOBALS['TYPO3_DB'];
index e167824..3fcb4db 100644 (file)
@@ -37,7 +37,7 @@ class RepositoryRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
         */
        public function initializeObject() {
                /** @var $defaultQuerySettings \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface */
-               $defaultQuerySettings = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
+               $defaultQuerySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
                $defaultQuerySettings->setRespectStoragePage(FALSE);
                $this->setDefaultQuerySettings($defaultQuerySettings);
        }
index 59375a7..f95520e 100644 (file)
@@ -127,7 +127,7 @@ class ConfigurationUtility implements \TYPO3\CMS\Core\SingletonInterface {
                if (strlen($rawConfigurationString) > 0) {
                        $extensionPathInformation = $GLOBALS['TYPO3_LOADED_EXT'][$extensionKey];
 
-                       $tsStyleConfig = $this->objectManager->create('TYPO3\\CMS\\Core\\TypoScript\\ConfigurationForm');
+                       $tsStyleConfig = $this->objectManager->get('TYPO3\\CMS\\Core\\TypoScript\\ConfigurationForm');
                        $tsStyleConfig->doNotSortCategoriesBeforeMakingForm = TRUE;
 
                        $theConstants = $tsStyleConfig->ext_initTSstyleConfig(
index 1a59da3..bcc1c7d 100644 (file)
@@ -152,7 +152,7 @@ class DependencyUtility implements \TYPO3\CMS\Core\SingletonInterface {
                                                $highest = '';
                                        }
                                        /** @var $dependencyObject \TYPO3\CMS\Extensionmanager\Domain\Model\Dependency */
-                                       $dependencyObject = $this->objectManager->create('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency');
+                                       $dependencyObject = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency');
                                        $dependencyObject->setType($dependencyType);
                                        $dependencyObject->setIdentifier($dependency);
                                        $dependencyObject->setLowestVersion($lowest);
index 1af0038..d974f10 100644 (file)
@@ -56,7 +56,7 @@ class UpdateScriptViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\ActionVie
 
                // If the "class.ext_update.php" file exists, build link to the update script screen
                /** @var $updateScriptUtility \TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility */
-               $updateScriptUtility = $this->objectManager->create('TYPO3\\CMS\\Extensionmanager\\Utility\\UpdateScriptUtility');
+               $updateScriptUtility = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\UpdateScriptUtility');
                if ($updateScriptUtility->checkUpdateScriptExists($extensionKey)) {
                        $uriBuilder = $this->controllerContext->getUriBuilder();
                        $action = 'show';
index bb81e5c..f774b31 100644 (file)
@@ -87,7 +87,7 @@ class ConfigurationUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCas
                $configurationUtility->_set('objectManager', $objectManagerMock);
                $objectManagerMock
                        ->expects($this->once())
-                       ->method('create')
+                       ->method('get')
                        ->with('TYPO3\\CMS\\Core\\TypoScript\\ConfigurationForm')
                        ->will($this->returnValue($tsStyleConfig));
 
index ad4b5e5..b42a7bb 100644 (file)
@@ -44,9 +44,9 @@ class DependencyUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                ));
                /** @var $dependencyUtility \TYPO3\CMS\Extensionmanager\Utility\DependencyUtility */
                $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('dummy'));
-               $objectManagerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('create'));
+               $objectManagerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get'));
                $dependencyModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency', array('dummy'));
-               $objectManagerMock->expects($this->any())->method('create')->will($this->returnValue($dependencyModelMock));
+               $objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($dependencyModelMock));
                $dependencyUtility->_set('objectManager', $objectManagerMock);
                $objectStorage = $dependencyUtility->convertDependenciesToObjects($serializedDependencies);
                $this->assertTrue($objectStorage instanceof \SplObjectStorage);
@@ -66,9 +66,9 @@ class DependencyUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                ));
                /** @var $dependencyUtility \TYPO3\CMS\Extensionmanager\Utility\DependencyUtility */
                $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('dummy'));
-               $objectManagerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('create'));
+               $objectManagerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get'));
                $dependencyModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency', array('setIdentifier'));
-               $objectManagerMock->expects($this->any())->method('create')->will($this->returnValue($dependencyModelMock));
+               $objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($dependencyModelMock));
                $dependencyUtility->_set('objectManager', $objectManagerMock);
                $dependencyModelMock->expects($this->at(0))->method('setIdentifier')->with('php');
                $dependencyModelMock->expects($this->at(1))->method('setIdentifier')->with('typo3');
@@ -139,9 +139,9 @@ class DependencyUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $serializedDependencies = serialize($dependencyString);
                /** @var $dependencyUtility \TYPO3\CMS\Extensionmanager\Utility\DependencyUtility */
                $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('dummy'));
-               $objectManagerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('create'));
+               $objectManagerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get'));
                $dependencyModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency', array('setHighestVersion', 'setLowestVersion'));
-               $objectManagerMock->expects($this->any())->method('create')->will($this->returnValue($dependencyModelMock));
+               $objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($dependencyModelMock));
                $dependencyUtility->_set('objectManager', $objectManagerMock);
                $dependencyModelMock->expects($this->atLeastOnce())->method('setLowestVersion')->with($this->identicalTo($returnValue[0]));
                $dependencyModelMock->expects($this->atLeastOnce())->method('setHighestVersion')->with($this->identicalTo($returnValue[1]));
index b12dba0..45a56ff 100644 (file)
@@ -88,7 +88,7 @@ class LanguageController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
                $actionName = $this->request->getControllerActionName();
                if (in_array($actionName, $this->jsonActions)) {
                        $viewObjectName = 'TYPO3\\CMS\\Lang\\View\\Language\\' . ucfirst($actionName) . 'Json';
-                       $this->view = $this->objectManager->create($viewObjectName);
+                       $this->view = $this->objectManager->get($viewObjectName);
                        $this->view->setControllerContext($this->controllerContext);
                        $this->view->initializeView();
                }
@@ -105,7 +105,7 @@ class LanguageController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
         */
        public function indexAction(\TYPO3\CMS\Lang\Domain\Model\LanguageSelectionForm $languageSelectionForm = NULL, $extensions = NULL) {
                if ($languageSelectionForm === NULL) {
-                       $languageSelectionForm = $this->objectManager->create('TYPO3\\CMS\\Lang\\Domain\\Model\\LanguageSelectionForm');
+                       $languageSelectionForm = $this->objectManager->get('TYPO3\\CMS\\Lang\\Domain\\Model\\LanguageSelectionForm');
                        $languageSelectionForm->setLanguages($this->languageRepository->findAll());
                        $languageSelectionForm->setSelectedLanguages($this->languageRepository->findSelected());
                }
index df3c557..a6e0ba8 100644 (file)
@@ -79,7 +79,7 @@ class ExtensionRepository {
 
                        foreach ($availableAndInstalledExtensions as $entry) {
                                /** @var $extension \TYPO3\CMS\Lang\Domain\Model\Extension */
-                               $extension = $this->objectManager->create(
+                               $extension = $this->objectManager->get(
                                        'TYPO3\CMS\Lang\Domain\Model\Extension',
                                        $entry['key'],
                                        $entry['title'],
index c8cce9f..2a99660 100644 (file)
@@ -106,7 +106,7 @@ class LanguageRepository {
                                        $label = htmlspecialchars($language);
                                }
 
-                               $this->languages[$locale] = $this->objectManager->create(
+                               $this->languages[$locale] = $this->objectManager->get(
                                        'TYPO3\CMS\Lang\Domain\Model\Language',
                                        $locale,
                                        $label,
index 22ec86f..e338566 100644 (file)
@@ -38,7 +38,7 @@ class SysNoteRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
         * @return void
         */
        public function initializeObject() {
-               $querySettings = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
+               $querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
                $querySettings->setRespectStoragePage(FALSE);
                $this->setDefaultQuerySettings($querySettings);
        }