Most entities you meet in Drupal 7 are pretty complex objects stored in a local database. That's not something the field system expects. The field system, in fact, will never use more than entity_extract_ids
to interface with your entities by design. Both that function and the field system will use metadata from hook_entity_info
so that can't be skipped. This is how you can interact with the fields system if you just pull some entity data out of thin air (like a web service):
$skeleton_entity = entity_create_stub_entity($entity_type, array($entity_id, $revision_id, $bundle));
field_attach_load($entity_type, array($entity_id => $skeleton_entity));
The $revision_id and the $bundle are optional. Every other attach function has a similar signature. Happy skeleton coding!
Commenting on this Story is closed.
Thanks for posting this! I've been wondering if there was a way to do this for a while but didn't know where or what exactly to ask.
Does this mean we can design an entity type which data are all from remote like restful service?
so when i add new entity or edit ,a post-based restful call to remote service is given at backend? when i view some entities , what is happen just like we do with views module + custom query plugin?
I am very curious and excited to see this happen,and hungry about more detail or document.