I am trying to use the class defined render_class to populate data in views and on pages using hook_ENTITY_TYPE_view(). However, hook_ENTITY_TYPE_view takes in a EntityInterface object instead of an Entity object. This is causing the following error to be thrown:
TypeError: Argument 1 passed to Drupal\my_module\Extrafield\ElementsResearchInterests::render() must be an instance of Drupal\Core\Entity\Entity, instance of Drupal\node\Entity\Node given
I think the ExtrafieldRenderClassInterface should also use EntityInterface as well. I've tested this out locally and it appears to work.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | extrafieldRenderClassInterface_should_probably_use_EntityInterface-3047205-3.patch | 1.97 KB | asrob |
| #2 | use-EntityInterface-3047205-01.patch | 2.04 KB | zipymonkey |
Comments
Comment #2
zipymonkey commentedNot super familiar with D8 so I might be completely off base with this issue but I've attached a patch for review.
Comment #3
asrobAdded a new patch based on coding standard.
Comment #4
guietc commentedPatch #3 is working perfectly.
Comment #5
david.carmona commentedPatch #3 solves the error and works perfectly on 8.8.1
Thanks!
Comment #6
abrammThis was also raised as https://www.drupal.org/project/extrafield_views_integration/issues/3161229 ; I've combined both patches.
Comment #8
abrammCommitted to 8.x-1.x.