Allow setting custom storage on FieldStorageConfig

Created on 20 September 2015, over 8 years ago
Updated 12 September 2023, 9 months ago

Problem/Motivation

There is a valid use case to support creating configurable fields, whether through the UI or in code, that have custom storage.

With base fields this is simple, we can just call setCustomStorage(TRUE) and we're done. No field tables will get created for that field. However, if you want to implement this using base fields you can, but you would need to take care of your field configuration for instances, and settings etc...

However, this is not possible right now if you are using a configurable field, and the FieldStorageConfig class. hasCustomStorage is hard coded to FALSE. To achieve this currently, you need to alter the field definition in hook_entity_field_storage_info_alter, and wrap the FieldStorageConfig instance with a decorator class to override the custom storage. Like https://github.com/damiankloip/og/blob/audience-field-custom-storage/src...

Proposed resolution

Add $custom_storage as a property and exportable configuration property for FieldStorageConfig objects. We can still default this to FALSE, but allow configurability. In the future we can then apply this to any configurable field easily to suit any use cases.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Fixed

Version

8.0 ⚰️

Component
FieldΒ  β†’

Last updated 2 days ago

Created by

πŸ‡¬πŸ‡§United Kingdom damiankloip

Live updates comments and jobs are added and updated live.
  • Contributed project blocker

    It denotes an issue that prevents porting of a contributed project to the stable version of Drupal due to missing APIs, regressions, and so on.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024