Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 296253

Make buildBundleFieldDefinitions use Bundle Classes for building bundleFieldDefinitions

$
0
0

Problem/Motivation

With Drupal 9.3.x came the very useful addition of Bundle Classes.

When I jumped into using this new feature, the Bundle Classes seemed like the perfect place to provide bundle specific field definitions via the bundleFieldDefinitions method, as all variations of bundle fields could live in their own class.

However, the buildBundleFieldDefinitions method on the EntityFieldManager responsible for building the list of bundle specific field definitions does not use Bundle Classes and will only ever try to call bundleFieldDefinitions on the base Entity class, meaning that you cannot define bundle specific fields in the Bundle Class.

Steps to reproduce

Create a Bundle Class as per the documentation and add a method of bundleFieldDefinitions to it. This method is never called and so any field definitions returned for it are never registered.

Proposed resolution

Modify the buildBundleFieldDefinitions method to check for and use a Bundle Class for locating bundleFieldDefinitions before falling back to the Entity Class as default.


Viewing all articles
Browse latest Browse all 296253

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>