Closed (fixed)
Project:
Panelizer (obsolete)
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Nov 2012 at 12:38 UTC
Updated:
18 Dec 2012 at 05:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
darrenmothersele commentedpatch attached.
Comment #2
merlinofchaos commentedThere is simply no consistent way that the entity can be found in hook_entity_view. In core, it's usually '#' . $entity_type, except for $user and except for $term.
Now, your custom entity is doing it yet another different way. The answer is NOT to hardcode your custom way into the system.
From looking at this, I think what we really should be doing is creating a method on the handler so that each individual plugin can tell us where the entity will be located. So something like this:
$entity = $handler->get_entity_view_entity($build)
Then the default can use '#' . $entity_type as it does now, and then all the exceptions that are currently in that code can move to their entity. Your entity type can define that to match the location that you're using.
It's worth noting that if Panelizer can't find it using '#' . $entity_type, other modules that do things with hook_entity_view won't be able to either. The initial code that Panelizer got for this is from display suite, for example, but it's not the only place I've seen code like this.
Comment #3
merlinofchaos commentedHere's a quick, completely untested patch to test out this concept.
Comment #4
merlinofchaos commentedThis one will protect against notices in case the entity is somehow unfindable.
Comment #5
darrenmothersele commentedThis custom entity was created by simple extension from the Entity API, so I guess there would be plenty of other custom entities around where the entity is found in ['#entity']. Having a method for this on the handler does seem like a better solution, thanks.
Patch in #4 is working for me.
Comment #6
merlinofchaos commentedCommitted and pushed!
Comment #7
betz commentedI have running latest dev, and i only see node, taxonomy and user as entities.
I have custom entities created with the entity construction kit.
Comment #8
merlinofchaos commentedThis patch doesn't automatically panelize any entity you might have; entities still need some code to be panelized. Entity Construction Kit would need to provide a panel plugin in order to have its custom entities panelized.
Reverting to proper status.