Issue Feature Closed

#66623Make mapSingleRow public to avoid unnessesary database access

Jan Kiesewetter 04/28/15, 11:59 updated 12/18/23, 11:50

Description

In case of content elements build with Extbase and Fluid or other datasources the DataMapper can be used to transfer an array to an object.

I use the following to transfer the already available data array of a content element to my content element object:
https://bitbucket.org/t3easy_de/basecontent/src/b3f3f8b2faeaf00bef75c35a99c063342b0b592b/Classes/Controller/ContentObjectController.php?at=develop#cl-47

This avoids the injection and call to the repository and use the findByUid(data[‘uid’]) and at the end do the same and call the DataMapper.

Could we make the mapSingleRow public and define “map” and “mapSingleRow” as api?

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 6

  1. Susanne Moog commented and changed status New Needs Feedback 03/03/19, 15:14

    The whole DataMapper is internal and will likely stay that way. Can you maybe rephrase the ticket to articulate what you want to achieve and why?

  2. Jan Kiesewetter commented 03/04/19, 10:25

    I used the DataMapper to build an object of the data array already available by an extbase content element.
    In the meantime DataProcessors are available and are perfect for simple content elements with not that complex content elements.
    But for more complex content elements build with Extbase it’s helpfull to get the content element as an object.
    Using `\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper->map` prevents an additional sql query as the data of the CE is already fetched and you don’t need a repository class for the CE.

    The DataMapper was marked internal on 1 Oct 2018, long after the issue was created:
    https://github.com/TYPO3/TYPO3.CMS/commit/65a5511149dbabeb58fc86d9c4f66188ea040d90#diff-a8aa95385a4a9a2e39c52f857dbc0e28R21

  3. Susanne Moog commented and changed tracker Task Feature status Needs Feedback New 03/04/19, 18:14

    Ok, got the case.

    Not sure if the DataMapper of Extbase would be the way to go or some more generic array-to-object mapper which could be integrated in the core but one way or the other, the use case is valid.

    (Yes, I know that the whole class was marked internal by annotation last year, but extbase was one part which used @api to annotate public api instead of the other way around before that IIRC)

  4. Georg Ringer changed Sprint Focus Needs Decision 03/24/20, 23:58

  5. Stefan Froemken commented and changed status New Needs Feedback 06/16/23, 23:50

    Hello,

    is this feature still needed?
    I mean: It’s easy to wrap your data into an array and use map() method without any problems.
    The map() method in DataMapper has not changed since over 8 years.
    Further you can implement your own simple DataMapper like that: https://github.com/jweiland-net/maps2/blob/TYPO3_6-2/Classes/Utility/DataMapper.php without all these language and TCA checks.

    Stefan

  6. Christian Kuhn commented and changed status Needs Feedback Closed 12/18/23, 11:50

    Hey.

    I hope we don’t disturb anyone by closing the issue for now: It seems unlikely the DM in extbase is reworked for now and there haven’t been many changes for years as Stefan said. As far as I can see, map() does not fire DB calls / anymore? If this is a pressing issue, we could still make the method public. Let’s do that in a fresh issue in case this is still an issue.