Problem/Motivation
When working on #2593379: Analyze/improve/fix handling of bubbleable metadata in entity_embed we realised that there are many functions in the trait that are pure wrappers around entity operations. It would be better if we'd rely on core APIs and simplify our code.
Proposed resolution
- Remove loadEntity(), loadMultipleEntities(), canRenderEntity(), canRenderEntityType(), buildEntity()
- Refactor code that uses them to call core APIs directly instead
- Remove functions that are providing dependencies (entity manager, module handler, plugin manager), inject where appropriate
At this point only functions that deal with building of the render array are left. Rename trait to better reflect this fact and mark it @internal.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | interdiff.txt | 15.04 KB | slashrsm |
| #10 | 2760407_10.patch | 56.52 KB | slashrsm |
| #8 | interdiff.txt | 9.24 KB | slashrsm |
| #8 | 2760407_8.patch | 54.32 KB | slashrsm |
| #7 | clean_up-2760407-7.patch | 45.35 KB | thenchev |
Comments
Comment #2
slashrsm commentedComment #3
thenchev commentedHere is the initial patch. On localhost I have some test fails but they look weird, might be because of my installation. Uploading for now to see what the test bot says.
p.s. didn't rename the trait yet. Still thinking about that.
Comment #5
thenchev commentedThis should fix tests.
Comment #6
slashrsm commentedThis member is already defined on the parent class.
Already set in parent constructor.
Maybe just rename it to EntityEmbedHelperTrait.
Can we keep using
$this->form? Only two classes use it and it is marked as internal.Let's make sure that this is set to NULL of the entity does not exist.
Comment #7
thenchev commentedEverything from #6 should be covered.
Comment #8
slashrsm commentedMinor update.
Comment #9
samuel.mortensonMy only suggestion would be to create a rendering service instead of a trait - the two dependencies required to use the trait aren't used anywhere else and this way you would only have to include one service, which could potentially reduce code.
Comment #10
slashrsm commentedMakes sense.
Comment #11
samuel.mortensonLooks good to me.
Comment #12
slashrsm commentedCommitted. Thanks!