Problem/Motivation
The StyleEntityReferenceItem class appears unnecessary. It is almost a wholesale copy/paste from the core EntityReferenceItem class. This looks like a place we could refactor and remove a bunch of code from the style_entity module.
There are indeed a few niceties that come along with the custom field type.
1. "Style Entity reference" appears as an option in the "Select a field type" dropdown when adding a field to an entity.
Unfortunately, it also make a bunch of unwanted and probably invalid options appear like field_ui:style_entity_reference:taxonomy_term. I set this issue as a task but these weird fields probably make this more of a bug.

Luckily, "Styles" can easily appear in the list of Reference fields simply by adding common_reference_target = TRUE, to the annotation for the Styles entity type.
2. Having a dedicated field type for style entities makes the following logic very simple:
if ($field->getType() == 'style_entity_reference') {
$style_field = $delta;
}
Instead we'd have to check if it's an entity_reference field and then load the storage to check if the target_type is styles. But that's not too bad.
Proposed resolution
1. Make an update to account for point #1 above
2. Make an update to account for point #2 above.
3. Remove StyleEntityReferenceItem
4. Remove StyleEntityReferenceFormatter
5. Remove schema related to #3 and #4
6. Remove style_entity_field_widget_info_alter
7. Add an update hook (ahh!)
8. Update config in test module
| Comment | File | Size | Author |
|---|---|---|---|
| Screen Shot 2022-08-05 at 10.13.12 AM.png | 183.8 KB | danflanagan8 |
Issue fork style_entity-3302083
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
danflanagan8Turns out we can't remove the style_entity_reference field type yet because I get this error during the updates:
So instead I'm just deprecating it and hiding it form the UI. We'll have to wait til later to remove it.
Comment #5
danflanagan8