Updated: Comment #0

Problem/Motivation

Hal's entity normalizer assumes that the entity bundle key is 'type' during denormalizing.

Proposed resolution

Inject the entity manager, get the info, use the real bundle key

Remaining tasks

Review
Tests - it looks like there are no tests at all for denormalizing of entities so not sure where to put them.

User interface changes

None

API changes

None

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan’s picture

FileSize
916 bytes
2.49 KB

Actually, we have the entity manager, lets use it instead of entity_create.

Status: Needs review » Needs work

The last submitted patch, entity-normalizer.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
FileSize
617 bytes
3.46 KB

Needed to set the entityManager on the normalizer in the tests.

Berdir’s picture

damiankloip’s picture

Yes, patch berdir mentions above already does this approach, so it's good they are aligned.

linclark’s picture

Tests - it looks like there are no tests at all for denormalizing of entities so not sure where to put them.

I'm not sure I understand correctly. What about DenormalizeTest?

damiankloip’s picture

That's what I was thinking! :)

larowlan’s picture

Whoops, how'd I miss that!

Berdir’s picture

3: entity-normalizer.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 3: entity-normalizer.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
5.93 KB

Let's start this again. The above patch does not apply anymore, but pretty much none of it is the same anymore, since we now inject the deps into these services. Also making the change to inject module handler while we are changing the constructors..

Let's get this ok again, then maybe add a test case for this.

Berdir’s picture

Looks good.

A test could be done by adding a test using terms similar to NodeTest? that explodes right now if you try to denormalize it.

maybe also unset the type from $data then, to avoid setting it twice, similar to the langcode in the ConfigField issue?

damiankloip’s picture

FileSize
6.03 KB
775 bytes

I have added the unset for the bundle in $data, that makes alot of sense :)

Do we need to add an additional test for this, the fact that we have made these changes to handle the bundle name generically and our current tests work cover this?

Berdir’s picture

I think we do, given the amount of broken things in hal, I wouldn't be surprised if more about terms is broken :)

That said, I'm adding tests for normalizing nodes and terms and back in #2219795: Config entity references broken and other bugs, do we want to merge the patches maybe? There's also @yched's issue about simplfying the field normalizer classes further than I did referenced there, we could merge that in too. Would make it easy to get that stuff in with proper test coverage, although the patches are getting bigger...

Berdir’s picture

Status: Needs review » Closed (duplicate)

Ok, the latest patch is now in #2219795: Config entity references broken and other bugs, which made that pass :)