Is there a way to get a list of entity reference fields by field type (similar to what is produced by
$all_reference_fields = $this->entityFieldManager->getFieldMapByFieldType('entity_reference');) but filtered down to just list the entity reference fields that have target entity types and bundles that match a specified list.
I'm not seeing anything in the entityFieldManager that would make it easy to filter the results of the
getFieldMapByFieldType() down to just specific reference fields I'm looking for, because the mapping doesn't contain any of the field's storage information, that contains the list of target bundles and handlers.
Looks like the entity_reference module in core doesn't provide any services that would be the logical place for something like this, so my current thinking is that I'll need to do this in two steps:
- Work through every single entity type in the field map, and call
buildFieldStorageDefinitions($entity_type);or something of that nature, to figure out the target
entity_type:bundle_namecombinations, and track down fields that reference
'taxonomy_term:tag'. This seems horribly inefficient, due to the sheer number of entity_reference type fields in this site, so maybe there is a better way to do this step?
In an ideal world, there'd be just a set of database calls I could make, or even a service in core for entity_reference module! (wishful thinking) ;)