Problem/Motivation
My custom enhancer plugin is not receiving anything in the $context variable. When I backtrace, the context seems to be lost in ContentEntityDenormalizer::prepareInput() line 62:
$field_value[$key] = $enhancer ? $enhancer->transform($individual_field_value) : $individual_field_value;
Custom enhancers' transform() method allows for a second parameter, $context, but evidently core enhancers' does not.
I see that there were a couple of similar issues fixed 6 years ago, but this one (at least) remains.
Proposed resolution
Check whether $enhancer->transform() allows a $context parameter, perhaps by using instanceof, and if so, pass it the entity type, bundle, and field name in the $context.
Issue fork jsonapi_extras-3541582
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
benstallings commentedComment #3
benstallings commentedComment #5
benstallings commentedComment #7
bbralaContext is great to have available there yeah, i do see a test failure though, which does seem to point to an issue?
Comment #8
bbralaHad claude do a review run:
Comment #9
bbralaComment #10
benstallings commentedComment #11
bbralaThanks!