The content entity datasource currently checks explicitly for the EntityAdapter class in several occasions where it receives a ComplexDataInterface object and wants to make sure getValue() will return an entity.

However, I'm pretty sure the class is an implementation detail and in no way "stable" or "guaranteed", so it would be better to find an alternative.
One easy solution would be to just call getValue() first and then check whether that value implements EntityInterface – a much cleaner and more direct check.

Or, with just slightly more work, we could add a method getEntity() which returns either an EntityInterface or NULL and does one or more checks for this. E.g., with this we could very easily catch the case that the ComplexDataInterface object could itself implement EntityInterface.

Comments

drunken monkey created an issue. See original summary.

sdstyles’s picture

Status: Active » Needs review
StatusFileSize
new2.84 KB

I chose second method, because seems to be a cleaner way, please advice If I did something wrong.
Thanks

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

This looks great.

drunken monkey’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.12 KB
new2.78 KB

Yep, great work, thanks a lot!

I do have a few minor nit-picks regarding the documentation, and I think I'd rather write the getEntity() method a bit more concisely, but on the whole it's a great job.
(I also moved the method up in the class file, but didn't include that in the interdiff.)

drunken monkey’s picture

StatusFileSize
new1.05 KB
new3.58 KB

One small oversight.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

drunken monkey’s picture

Thanks for reviewing!
Committed.
Thanks again, sdstyles!

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.