Project

General

Profile

Actions

Feature #101125

open

Ability to convert Domain Models to Array

Added by Aristeidis Karavas 11 months ago. Updated 7 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase
Start date:
2023-06-20
Due date:
% Done:

0%

Estimated time:
PHP Version:
8.2
Tags:
extbase, domain, model, array
Complexity:
Sprint Focus:

Description

In the same context with this https://forge.typo3.org/issues/101124, it would be very practical if there was a function in the AbstractEntity , which converts the Model to array.

Technology is moving fast, and headless and communication between systems are made mostly with json strings. Currently, one has to create a method in the domain model which return the values as arrays, but this also could be PITA if an extension has 10+ models and relations. Specially now that with TYPO3 12, we have Webhooks and Reactions , which makes the communication between systems very easy.

Solution
Create a method in AbstractEntity which processes everything (FileReferences, Relations) and return everything as an array


Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Feature #101124: Make Templates optional in ExtbaseNeeds FeedbackStefan Froemken2023-06-20

Actions
Actions #1

Updated by Benni Mack 10 months ago

Actions #2

Updated by Stefan Froemken 10 months ago

Hello Karavas,

You can use \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getGetableProperties($object); to do so in your controller.

I know, that this method needs a further method to do its job recursive. Maybe I can create a patch for that.

Would that be an option for you?

Stefan

Actions #3

Updated by Aristeidis Karavas 7 months ago

Hallo Stefan,

calling another class to modify the current called Model, i think it is too much. The same could be achieved by not calling the model at all and just make a QueryBuilder request with all the joins. A more suitable approach would be a function inside the model which returns everything as array, so the developer could just do something like that: $object = $this->someRepository->findByUid()->toArray

Not saying that the current implementation it is not a solution, but the other one would be more practical and understandable, specially when it comes to documentation

If it is too much, or not possible with the current state of TYPO3, sure, creating a patch for the ObjectAccess would be ok

Aris

Actions

Also available in: Atom PDF