[FLOW3-general] Mapping data on existing objects

Pascal Jungblut typo3 at pascalj.com
Sat Jul 9 12:11:41 CEST 2011


Hi Regine,

On 08.07.2011, at 13:00, Regine Rosewich wrote:
> Hi Pascal (Jascal?),

yepp, that's me on Freenode.

> the bad news is, that 
> 1. you have to handle both Actions (Read the Data, Update the Data) with
> separate ExtDirect Actions(Controller-Methods / have a look at the "Service"
> branch of the "Classes" folder in the TYPO3V5 Package)
> 2. If the ExtJS - update Request always contains all properties of the
> object to be updated (including the persistence_identifier), the following
> controller-method-example works perfectly.

As I said: it's not that simple, unfortunately:

>> The problem here is that I can not annotate the
>> updateAction with "@var F3\Foo\Domain\Model\Object" because I only know
>> the object's type on runtime.

So I ended up using some internal methods of FLOW3. To update an object, I use:

F3\FLOW3\Persistence\Generic\DataMapper->mapToObject().

It takes a configuration array that also contains the data and returns the updated object.
To create a new object I use the PropertyMapper:

F3\FLOW3\Property\PropertyMapper->convert()

It takes the type of the object and the data and creates a new object that can be handed over to the repository.
Maybe there's a more elegant solution. If so, please let me know!

Regards
Pascal


More information about the FLOW3-general mailing list