[TASK] use the objectManager to create empty domain objects
authorMarkus Günther <mail@markus-guenther.de>
Sat, 21 Jul 2012 12:48:28 +0000 (14:48 +0200)
committerFelix Oertel <mehl@foertel.com>
Sat, 21 Jul 2012 14:03:36 +0000 (16:03 +0200)
The Tx_Extbase_Persistence_Mapper_DataMapper uses the objectContainer
(Tx_Extbase_Object_Container_Container) for creating an empty object
without calling the construct.

The problem is that except the objectManager no one should use the
objectContainer. So this patch adds a wrapper class to the object
manager communicates with the objectContainer.

Change-Id: I2a2f9d68c0ac0c14a47723ea901c974b7ccc6c5e
Resolves: #13816
Release: 6.0
Reviewed-on: http://review.typo3.org/12973
Reviewed-by: Felix Oertel
Tested-by: Felix Oertel
typo3/sysext/extbase/Classes/Object/ObjectManager.php
typo3/sysext/extbase/Classes/Object/ObjectManagerInterface.php
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php

index b0d7207..a501860 100644 (file)
@@ -138,5 +138,16 @@ class Tx_Extbase_Object_ObjectManager implements Tx_Extbase_Object_ObjectManager
 
                return $instance;
        }
+
+       /**
+        * Create an instance of $className without calling its constructor
+        *
+        * @param string $className
+        * @return object
+        * @api
+        */
+       public function getEmptyObject($className) {
+               return $this->objectContainer->getEmptyObject($className);
+       }
 }
 ?>
\ No newline at end of file
index f85b189..1e7be18 100644 (file)
@@ -70,5 +70,14 @@ interface Tx_Extbase_Object_ObjectManagerInterface extends t3lib_Singleton {
         * @api
         */
        public function create($objectName);
+
+       /**
+        * Create an instance of $className without calling its constructor
+        *
+        * @param string $className
+        * @return object
+        * @api
+        */
+       public function getEmptyObject($className);
 }
 ?>
\ No newline at end of file
index 77b7e76..6e6b5c7 100644 (file)
@@ -88,11 +88,6 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
        protected $objectManager;
 
        /**
-        * @var Tx_Extbase_Object_Container_Container
-        */
-       protected $objectContainer;
-
-       /**
         * Injects the identity map
         *
         * @param Tx_Extbase_Persistence_IdentityMap $identityMap
@@ -160,14 +155,6 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
        }
 
        /**
-        * @param Tx_Extbase_Object_Container_Container $objectContainer
-        * @return void
-        */
-       public function injectObjectContainer(Tx_Extbase_Object_Container_Container $objectContainer) {
-               $this->objectContainer = $objectContainer;
-       }
-
-       /**
         * Maps the given rows on objects
         *
         * @param string $className The name of the class
@@ -234,7 +221,7 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
                // Note: The class_implements() function also invokes autoload to assure that the interfaces
                // and the class are loaded. Would end up with __PHP_Incomplete_Class without it.
                if (!in_array('Tx_Extbase_DomainObject_DomainObjectInterface', class_implements($className))) throw new Tx_Extbase_Object_Exception_CannotReconstituteObject('Cannot create empty instance of the class "' . $className . '" because it does not implement the Tx_Extbase_DomainObject_DomainObjectInterface.', 1234386924);
-               $object = $this->objectContainer->getEmptyObject($className);
+               $object = $this->objectManager->getEmptyObject($className);
                return $object;
        }
 
@@ -580,4 +567,4 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
        }
 
 }
-?>
\ No newline at end of file
+?>