Problem/Motivation
The interplay between the plugin ID and the group property on EntityReferenceSelection plugins is weird.
Despite improving the docs for this #2945789: Document quirks of Entity reference selection plugins while a fix is figured out, it's still confusing #3270898: Misleading documentation in \Drupal\Core\Entity\Annotation\EntityReferenceSelection. There is a long-standing issue to fix it #2649712: Entity reference selection plugins break when not following a weird ID pattern but no way forward.
I have an alternative suggestion: since the group property MUST conform to a certain pattern, remove it from the plugin attribute and derive it in the plugin manager.
The current rule is:
- group and id must be identical, OR
- if id is of the form foo:bar, group must be foo
Therefore, we can remove the group property from the attribute and set it in the plugin manager like this:
- if id does not contain a ':', set group to the same as the id
- if id is of the form foo:bar, set group to foo
We keep the concept of group, because it's used by EntityReferenceItem (see my comments on #3270898: Misleading documentation in \Drupal\Core\Entity\Annotation\EntityReferenceSelection for an explanation), but it's now impossible to get it wrong.