Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.
Overview
We currently have ClientServerConversionTrait
(added in #3478565: Add Entity Update controller) that converts client-side data shape into server-side data shape. We should create ServerClientConversionTrait
that converts server-side data shape into client-side data shape.
Proposed resolution
Create a ClientServerConversionTrait
trait, extract similar BE logic from ApiLayoutController::buildLayout()
and ApiConfigControllers::convertComponentTreeItemToLayoutModel()
. Add tests, profit.
Comments
Comment #2
wim leers@tedbow added
ClientServerConversionTrait
in #3478565: Add Entity Update controller.I know that @larowlan has a clear idea in his head for how we should approach this. (In another issue I commented in the past hour he was talking about a PHP value object to contain the client-side data model — but I can't find it now 😭)
Alternatively, I could imagine
::toClientSideRepresentation(): ClientSide
and::fromClientSideRepresentation(ClientSide $representation)
being added to:ComponentTreeItem
PageTemplate
Pattern
… and for them to share common logic using a trait.
I'm curious what @larowlan thinks 😊
Comment #3
wim leers@larowlan: perhaps you think we should close this in favor of #3489772: [PP-1] Add a param converter and DTO for XB data model? :)
Comment #4
wim leersWhile working on #3484678: Improve or remove ComponentSourceInterface::getClientSideInfo(), it became clear that a related challenge appeared there, which relates closely to what I wrote in #2. See https://git.drupalcode.org/issue/experience_builder-3484678/-/tree/34846..., described in #3484678-20: Improve or remove ComponentSourceInterface::getClientSideInfo(), @larowlan 🤓
Comment #5
wim leersComment #6
wim leersClientSideRepresentation
landed in #3484678: Simplify ComponentSourceInterface::getClientSideInfo(), introduce ClientSideRepresentation value object, and leverage it, but it's kinda like JSON:API'sCacheableNormalization
.It's not doing the much more advanced transformation that this issue is suggesting/implying. But … I'd definitely be interested in seeing it evolve towards that.
Curious to read @larowlan's thoughts!
Comment #7
larowlanLooking good Wim, great stuff