This patch adds Rules events for hook_ENTITY_view(). As the EntityAPIController already invokes the event, adding the Rules event definition in entity.rules.inc was enough. The event itself works, but I'm still facing problems when using the view mode variable in a data comparison condition (Fatal error: Unsupported operand types in includes/form.inc on line 2525). As this happens for the node view as well, this problem seems to be an Rules issue.

Comments

fago’s picture

indeed, options lists for event variables were completely broken in Rules as the wrappers didn't work in that case. I've just fixed that in entity + rules, so the node-view view-modes now work for me in Rules.

To fix the patch we'll need to add something like

+          // Add the entity-type for the options list callback.
+          'options list entity type' => 'node',

to the view-mode variable info array.

mh86’s picture

Status: Needs work » Needs review
StatusFileSize
new1.15 KB

Updated the patch for the latest Rules fix. Furthermore, the view mode variable will only be added to entities with some view modes.

fago’s picture

Status: Needs review » Fixed

thanks, committed.

mh86’s picture

Status: Fixed » Needs review
StatusFileSize
new1.62 KB

updated the patch to only expose the view event for entities with view modes. For the other entities we assume that they don't use entity view anyway.

fago’s picture

Status: Needs review » Fixed

thanks, works for me. committed.

Status: Fixed » Closed (fixed)

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