[BUGFIX] Fix and deprecate legacy creation of objects in repository
authorMarc Bastian Heinrichs <typo3@mbh-software.de>
Fri, 16 Nov 2012 14:43:54 +0000 (15:43 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sat, 17 Nov 2012 13:14:16 +0000 (14:14 +0100)
Since DI is used for instantiation of session and backend
objects, creating repository objects with makeInstance will fail. Add
legacy creation for this both objects to constructor and deprecate the
legacy creation

Fixes: #42968
Fixes: #42928
Releases: 6.0

Change-Id: Idc8aa7aadc2a4e43fdd938902dbd5f8c8098bf24
Reviewed-on: http://review.typo3.org/16484
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/extbase/Classes/Persistence/Repository.php

index dc348ad..eb009d2 100644 (file)
@@ -97,6 +97,7 @@ class Repository implements \TYPO3\CMS\Extbase\Persistence\RepositoryInterface,
         * Constructs a new Repository
         *
         * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
+        * @deprecated since Extbase 6.0.0; will be removed in Extbase 6.2 - Use objectManager to instantiate repository objects instead of GeneralUtility::makeInstance
         */
        public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager = NULL) {
                $this->addedObjects = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
@@ -106,10 +107,15 @@ class Repository implements \TYPO3\CMS\Extbase\Persistence\RepositoryInterface,
                if ($objectManager === NULL) {
                        // Legacy creation, in case the object manager is NOT injected
                        // If ObjectManager IS there, then all properties are automatically injected
+                       // @deprecated since Extbase 6.0.0, will be removed in Extbase 6.2
+                       \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
+
                        $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
                        $this->injectIdentityMap($this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\IdentityMap'));
                        $this->injectQueryFactory($this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QueryFactory'));
                        $this->injectPersistenceManager($this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager'));
+                       $this->injectBackend($this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\BackendInterface'));
+                       $this->injectSession($this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Session'));
                } else {
                        $this->objectManager = $objectManager;
                }