Get Bundle Field Name from Entity Definition

Created on 13 June 2023, over 1 year ago
Updated 26 August 2024, 3 months ago

Problem/Motivation

In the AutoEntityLabelForm the "Re-save" Option queries all affected entity IDs on form submission.

The code for this query uses a switch case for some entity types to determine the "bundle" field. It uses the field type as a fallback. This causes an error for all entity types which have the "bundle" key in another field.

Steps to reproduce

  1. Create a custom entity with bundles
  2. Make sure the bundle entity field is set something different than "type". E.g. "bundle" = "bundle",
  3. Create a bundle entity type
  4. Enable auto entity label for this bundle and check the "Re-Save" option
  5. The re-saving process will fail, because there is no "type" field.

Proposed resolution

Instead of assuming the bundle field, it can be accessed using $type_definition->getKey('bundle');.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024