Revert "[CLEANUP] remove deprecated repository constructor" 73/23173/3
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 18 Aug 2013 10:35:10 +0000 (12:35 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 18 Aug 2013 10:37:41 +0000 (12:37 +0200)
This breaks a lot of tests as is. Will be reintroduced
together with the neccessary refactorings.

This reverts commit 91bb179484f45fdbdc5a20f938c31e982847b11e

Change-Id: Icb319d4bfce550758241714cd9d344a1038441bc
Reviewed-on: https://review.typo3.org/23173
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/extbase/Classes/Persistence/Repository.php

index 9c8be55..3cef6a4 100644 (file)
@@ -85,12 +85,25 @@ 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) {
-               $this->objectManager = $objectManager;
-
+       public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager = NULL) {
                $nsSeparator = strpos($this->getRepositoryClassName(), '\\') !== FALSE ? '\\\\' : '_';
                $this->objectType = preg_replace(array('/' . $nsSeparator . 'Repository' . $nsSeparator . '(?!.*' . $nsSeparator . 'Repository' . $nsSeparator . ')/', '/Repository$/'), array($nsSeparator . 'Model' . $nsSeparator, ''), $this->getRepositoryClassName());
+               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->identityMap = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\IdentityMap');
+                       $this->persistenceManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
+                       $this->backend = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\BackendInterface');
+                       $this->session = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Session');
+               } else {
+                       $this->objectManager = $objectManager;
+               }
        }
 
        /**