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.

Comments

zipymonkey created an issue. See original summary.

zipymonkey’s picture

StatusFileSize
new2.04 KB

Not super familiar with D8 so I might be completely off base with this issue but I've attached a patch for review.

asrob’s picture

Assigned: zipymonkey » Unassigned
Status: Active » Needs review
StatusFileSize
new1.97 KB

Added a new patch based on coding standard.

guietc’s picture

Patch #3 is working perfectly.

david.carmona’s picture

Patch #3 solves the error and works perfectly on 8.8.1

Thanks!

abramm’s picture

This was also raised as https://www.drupal.org/project/extrafield_views_integration/issues/3161229 ; I've combined both patches.

  • abramm authored ef62c4a on 8.x-1.x
    Issue #3047205 by zipymonkey, asrob, Guietc, abramm, david.carmona:...
abramm’s picture

Status: Needs review » Fixed

Committed to 8.x-1.x.

Status: Fixed » Closed (fixed)

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