1

So I am creating a content and config entities - exactly like node and node type. After I've created them I've noticed that I can add fields to the config entities, which is ok but then I've realised that I'm working with two separate entity types, so I wonder how re Field API fields "transferred" from the config entity to the content entity?

  • What do you mean by transferred? What exactly happens and what you expected? – Mołot Dec 30 '13 at 15:17
2

This works essentially the same way as in Drupal 7.

Config entities like node types, custom block types, vocabularies and so on are used as storage and are then exposed as bundles of nodes, custom blocks, taxonomy terms, ...

There's not much magic involved, you can see what happens in e.g. node_entity_bundle_info() and taxonomy_entity_bundle_info(), so the modules have to do that part themself, you'll notice small differences there e.g. how they handle the bundle label.

The bundle_of annotation key was added recently that allows to explicitly define that relationship between two entity types, but it's currently only used by field_ui_entity_operation_alter() to automatically add operation links to the listings of node types, vocabularies and so on.

While it looks like you add the fields to config entities, you really add the field to the corresponding content entity for the given bundle. Just like it already was in 7.x, the only thing that really changed is all those different things now use the same API for storage, in 7.x, they were stored in separate tables and didn't have anything in common.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy