function entity_entity_type_build(array &$entity_types) {
  foreach ($entity_types as $entity_type) {
    if ($entity_type->get('bundle_plugin_type')) {
      $entity_type->setHandlerClass('bundle_plugin', BundlePluginHandler::class);
    }
  }
}

This forces the bundle_plugin handler class on entity types, which is bad DX. The code should first check that the entity types doesn't already specify a bundle_plugin handler class.

Comments

joachim created an issue. See original summary.

joachim’s picture

Title: allow entity types to specify theyr own bundle_plugin handler class » allow entity types to specify their own bundle_plugin handler class
foxtrotcharlie’s picture

Assigned: Unassigned » foxtrotcharlie
foxtrotcharlie’s picture

Status: Active » Needs review
StatusFileSize
new592 bytes

Is it as simple as just checking whether the entity type has a bundle_plugin handler class, and only if not do we set the default?

See attached patch or below:

function entity_entity_type_build(array &$entity_types) {
  foreach ($entity_types as $entity_type) {
    if ($entity_type->get('bundle_plugin_type')) {
      if (!$entity_type->hasHandlerClass('bundle_plugin')) {
        $entity_type->setHandlerClass('bundle_plugin', BundlePluginHandler::class);
      }
    }
  }
}
joachim’s picture

Status: Needs review » Reviewed & tested by the community

Yup, that's exactly it. Thanks for the patch!

  • bojanz committed 2dd2ee3 on 8.x-1.x authored by foxtrotcharlie
    Issue #3028705 by foxtrotcharlie, joachim: allow entity types to specify...
bojanz’s picture

Status: Reviewed & tested by the community » Fixed

No reason not to. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.