- 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 resultsAll 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. š
- š§šŖ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! šš
- š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
While working on š Improve or remove ComponentSourceInterface::getClientSideInfo() Active , it became clear that a subset of what's described in this issue's summary appeared there. See https://git.drupalcode.org/issue/experience_builder-3484678/-/tree/34846..., described in #3484678-20: Improve or remove ComponentSourceInterface::getClientSideInfo() ā , @larowlan š¤
- š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
š Improve or remove ComponentSourceInterface::getClientSideInfo() Active just landed. Even if this takes us in a different direction (because that was just an incremental improvement, not meant to be final), then that work should make this issue much simpler š
- Status changed to Postponed
6 months ago 11:40am 20 February 2025 - š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
š Simplify ClientServerConversionTrait::clientLayoutToServerTree() Active is in, which is another small step towards making this (or something like it) feasible.
- šŗšøUnited States tedbow Ithaca, NY, USA
I just noticed the comments at the end of
\Drupal\experience_builder\Controller\ClientServerConversionTrait::convertClientToServer
are wrong// Update the entity, validate and save. // Note: constructing ComponentTreeStructure from `layout` and // ComponentInputs from `model` also included validation. But that // included only structural validation, not semantical validation. // @see \Drupal\experience_builder\Plugin\Field\FieldType\ComponentTreeItem // @see \Drupal\experience_builder\Plugin\Validation\Constraint\ValidComponentTreeConstraintValidator // @see \Drupal\experience_builder\Plugin\Validation\Constraint\ComponentTreeMeetsRequirementsConstraintValidator return [ 'tree' => json_encode($tree, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT | JSON_THROW_ON_ERROR), 'inputs' => json_encode($inputs, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR | JSON_FORCE_OBJECT), ];
re "Update the entity, validate and save." we don't do any of this here any more, probably did from where ever this was refactored from .
Don't know if I should make a new issue or fix or this is going away in the current issue
- š¦šŗAustralia larowlan š¦šŗš.au GMT+10
I'm personally still in favour of this because
a) I want to see
\Drupal\experience_builder\Controller\ClientServerConversionTrait
gone. It's use in Patterns, PageRegions etc feels wrong
b) I want to see the static methods on that trait returned to non static methods on the service.
c) I don't want the controllers to have to work with the raw data, I want the request object to have upcast objects automatically