[TYPO3-mvc] Cloning Model and add to repository
Jochen Rau
jochen.rau at typoplanet.de
Tue Jun 15 11:33:52 CEST 2010
Hi Manfred.
On 2010-06-15, Manfred Rutschmann <manfred.rutschmann at revier.de> wrote:
> Am Mon, 14 Jun 2010 15:11:04 +0200 schrieb Sebastian Kurfürst:
>
>> $oldObject = ...
>> $newObject = new Tx_My_Object();
>>
>> $propertyMapper = t3lib
>> _div::makeInstance('Tx_Extbase_Property_Mapper'); // Singleton
>> $propertyMapper->map(array('property1', 'property2'), $oldObject,
>> $newObject);
>>
>> $this->myRepository->add($newObject);
>
> Hey Sebastian,
>
> i tried out your workaraound and get a strange error in the extbase mapper
> class:
>
> Fatal error: Call to a member function getClassSchema() on a non-object in
> C:\xampp170\htdocs\xxx\typo3\sysext\extbase\Classes\Property\Mapper.php on
> line 180
This is because the property mapper needs the reflection service to determine the property type. So an instance of the reflection service has to be injected to the property mapper before it can be used.
> $propertyMapper = t3lib_div::makeInstance('Tx_Extbase_Property_Mapper'); //
> Singleton
The property mapper isn't a singleton, but the reflection service is:
$propertyMapper = t3lib_div::makeInstance('Tx_Extbase_Property_Mapper');
$propertyMapper->injectReflectionService(t3lib_div::makeInstance('Tx_Extbase_Reflection_Service'));
should work. Keep in mind that this is no API and may change in future.
Regards
Jochen
More information about the TYPO3-project-typo3v4mvc
mailing list