0

I'm trying to convert a Drupal 7 site to Drupal 9 before D7 reaches EOL, and I had a custom module that had a lot of custom tables defined in Hook Schema, that would be joined together in different ways to handle a multi-step form made with the ctools form wizard. This site was originally created in Drupal 6, and updated to Drupal 7 while doing the minimum changes to the custom modules, so it predates the concept of Entities. The database structure of those tables is normalized, in 3rd normal form, because if you flattened it, would your end with millions of rows with mostly redundant information. The problem was that those tables existed in their own microcosm, not accessible to the rest of the site.

I've decided to rebuild everything from the ground up when doing the site upgrade, and I've also decided to drupalize this so the contents of these tables can be accessed by regular views, avoiding content duplication. This means that every old table will have to have it's own entity type. Fields will be basefields for performance, since I will need 50-100 fields in total, and every fiend added through the UI requires a join as far as I understand. If I need to add fields in the future, I will do it through a module update, not by adding them through the UI, so I don't need the entities to be fieldable.

After giving you this context, my actual question is, if I will only ever need 1 type of every entity bundle, do I really need entity bundles? What would entity bundles do for me?

  • You cannot create views of different entity types, but you can create views with same entity type and different bundles. – Hudri Jul 3 at 11:18
  • My plan to "join" the different entity types via entity reference fields (aka foreign keys in database lingo). I will use a view that checks around 10 entities joined this way. Is this not possible? Am I not understanding this correctly? – AxisAutomation Jul 3 at 11:29
  • You can add additional relations to other entity types in views (similar to SQL join more tables from other entity types), but you can use only one entity type as base table in views (similar to only one entity type in SQL select X from entity_base_table) – Hudri Jul 3 at 11:34
  • I get that. I still wonder, if I will have only one bundle per entity type, do I need to set up a configuration entity for the the bundle? What does having the entity able to have bundles provide me? I see no need for it, but I feel I'm missing something here. – AxisAutomation Jul 3 at 12:02
0

After giving you this context, my actual question is, if I will only ever need 1 type of every entity bundle, do I really need entity bundles? What would entity bundles do for me?

No, you don't need bundles. Configurable fields are stored in bundles. Since you don't want to configure fields you don't need bundles.

I still wonder, if I will have only one bundle per entity type, do I need to set up a configuration entity for the the bundle?

The core user entity is an example for a bundleless entity type for which you can configure bundle fields. It looks like having one bundle but there is no bundle config entity. The bundle fields use the entity type id as placeholder.

So even if you later need to add configurable fields, through UI or YAML, you don't need to set up a configuration entity for the bundle. See Adding Field To Bundle-less Entity On Installation Not Working

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.