Add a param converter and DTO for XB data model

Created on 26 November 2024, about 2 months ago

Overview

Methods such as those in ClientServerConversionTrait have logic around converting incoming request bodies into Typed data objects but also mix in some validation results

Proposed resolution

Move this to a data transfer object that is built from a routing param converter
Make the param converter utilise the serializer component?
Then controllers can just typehint on the DTO as a param and the logic around routing and validation can be lifted out of the controller.
The data transfer (value) object can have ::isValid ::getViolations and ::getModel/::getLayout/::getTree as required

User interface changes

πŸ“Œ Task
Status

Active

Version

0.0

Component

Data model

Created by

πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @larowlan
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Methods such as those in ClientServerConversionTrait have logic around converting incoming request bodies into Typed data objects but also mix in some validation results

    All of that is a stop-gap solution, the top priority should be resolving πŸ› Some components cannot be used in XB because UI prevents SDC props being named `name` Active , to evolve the client-side data model to support all known (current and ideally also future) needs.

    @larowlan Do you agree with resolving that issue first? I've started the conversations for that in the week before my paternity leave, to set the stage, but it has unfortunately not been followed through. 😞

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Seems reasonable to me

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    The intent/scope of this issue has never been super clear to me.

    Related discussion:

    Wim, Dec 19, 2024:

    πŸ€” This is a client-side/UI model. It feels wrong/off to put this logic in a pure server-side representation? πŸ™ˆ

    Wouldn't it be better to create a ClientSideModel typed object on the server side that can contain all the relevant transformation methods?

    Lee, Dec 19, 2024:

    Yes, I've been wanting to do this for a long time - see https://www.drupal.org/project/experience_builder/issues/3489772 πŸ“Œ Add a param converter and DTO for XB data model Active and !137

    Very very keen.

    On pure symfony API projects I have, we do this in request events so that controllers can type-hint the object and have zero logic of 'how do I take this request body and make something from it'. Realllllly keen to do that here. Thin controllers++

    β€” https://git.drupalcode.org/project/experience_builder/-/merge_requests/4..., for πŸ“Œ Implement auto-save of the page template config entity Active

    That sounds amazing, so if that's the intent for this issue, then hell yes! πŸ™πŸ˜„

Production build 0.71.5 2024