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.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 2707147-5--entity_adapter_checks.patch | 3.58 KB | drunken monkey |
Comments
Comment #2
sdstyles commentedI chose second method, because seems to be a cleaner way, please advice If I did something wrong.
Thanks
Comment #3
borisson_This looks great.
Comment #4
drunken monkeyYep, 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.)
Comment #5
drunken monkeyOne small oversight.
Comment #6
borisson_Comment #8
drunken monkeyThanks for reviewing!
Committed.
Thanks again, sdstyles!
Comment #9
drunken monkey