The drop is always movingYou know that saying about standing on the shoulders of giants? Drupal is standing on a huge pile of midgetsAll content management systems suck, Drupal just happens to suck less.Popular open source software is more secure than unpopular open source software, because insecure software becomes unpopular fast. [That doesn't happen for proprietary software.]Drupal makes sandwiches happen.There is a module for that

About entity / field interaction -- remote entities

Submitted by nk on Fri, 2011-05-06 08:19

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.

Submitted by linclark on Fri, 2011-05-06 16:43.

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.

Submitted by Anonymous on Sat, 2011-05-07 15:13.

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.