Using Drupal Core entities, I can create a stub entity (using entity_create_stub_entity()) and create a URL for it using the entity's URI callback.
This is because the stub entity is a stdObject, and the URI callback references its properties only - not any methods defined in the entity controller, since the object does not have the correct object class.
With using a stub Entity API object, this results in a fatal error, because entity_class_uri invokes the method uri(), which of course doesn't exist for stdObject.
How can i retrieve the URI for a stub entity?
The particular use case is creating a menu callback for arbitrary Entity API impelmentations.
Any help, or if someone can suggest a better approach to this problem, would be appreciated.
Comments
Comment #1
EvanDonovan commentedSubscribing.
See http://drupal.org/node/1207720#comment-4699104 for context on the original issue.
Note that this might actually have to become a core issue, since it affects all entities, not just those handled by the Entity API module. It is just more obvious with the Entity API module entities, since their uri's are often non-standard (i.e., not something like entity-name/%oid).
Comment #2
EvanDonovan commentedOne key example of an entity for which I'd like to be able to retrieve the uri in a generic fashion is Profile2. I'd like to be able to know when hook_menu() is called where the admin screen for an individual Profile2 entity is, so that there could be a Salesforce tab (local task) added.
Let me know if you need further clarification.
Comment #3
aaronbaumanI'm gonna go ahead and bump this up to a bug, until someone can explain to me why Entity API should cause a fatal error when calling entity_uri() on a stub entity.
Comment #4
EvanDonovan commentedI think the message actually came from Profile2's implementation of Entity API, not Entity API, strictly speaking, but maybe the issue does lie with Entity API.
Comment #5
aaronbaumanIIRC Profile2 is using Entity API's default controllers, so yeah, the root of the issue lies with Entity API.
Comment #6
fagoBecause it's no real entity, but just stub entity. It won't work all the API functions. Use entity_create() if you want to create a real entity.
>How do I retrieve the URI for a stub entity?
You can't. Load the entity.