Postponed
Project:
farmOS
Version:
4.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
22 Jan 2021 at 13:24 UTC
Updated:
29 Apr 2025 at 15:21 UTC
Jump to comment: Most recent
I am creating this issue as a place to start organizing thoughts/considerations around the future of our custom hook_farm_entity_bundle_field_info() and how that will need to be refactored if/when Drupal core adds more official support for code-defined bundle field definitions.
Note that we also started using BundleFieldDefinition fields for Consumer entity fields in #3207716: Use BundleFieldDefinition for additional Consumer fields.
Related core issue: #2346347: Finalize API for creating, overriding, and altering code-defined bundle fields
Relevant farmOS issues/threads:
TBD
TBD
(Hopefully none.)
(Hopefully none.)
(Hopefully none, other than the mechanism by which bundle fields are defined.)
Comments
Comment #2
m.stentaAs @paul121 noticed in #3192245: Storage is not created for fields created with hook_farm_entity_bundle_field_info until a new entity of that type is installed, the
FarmFieldFactoryclass currently usesFieldDefinitionInterfacefor all type-hinting, which leads to IDEs complaining because the code references properties/methods that are present onBaseFieldDefinitionclasses, but not on theFieldDefinitionInterfaceinterface.Explanation (copied from that issue thread):
Comment #4
m.stentaI pushed a commit that adds some
@todocomments linking back to this issue, for future reference.Comment #5
m.stentaThis is no longer the case - see last commit of #3192245: Storage is not created for fields created with hook_farm_entity_bundle_field_info until a new entity of that type is installed. We changed to
BaseFieldDefinitionfor parameter type hinting, which is correct becauseBundleFieldDefinitionis a child class, so even thoughFarmFieldFactorycan return either type, it can still useBaseFieldDefinitionfor all its type-hinting.Comment #6
m.stentaGeneralizing this issue a bit... we made the Consumer fields in to
BundleFieldDefinitions declared inhook_entity_base_field_info()(nothook_farm_entity_bundle_field_info()). These will also need to be refactored if/when core supports bundle fields.Comment #7
m.stentaComment #8
m.stentaComment #9
m.stenta