Problem/Motivation
Follow-up from #3252386: Use PHP attributes instead of doctrine annotations and pointed out by @xjm. We should document attribute discovery in the handbook.
https://www.drupal.org/docs/drupal-apis/plugin-api has a section on annotations, could add a parallel one, and add note in the annotations page pointing to it.
There'll also be lots of individual examples of plugins using annotations that need updating over time to use attributes instead, but these will need to wait for individual subsystems to support attributes.
Steps to reproduce
Proposed resolution
Added Attribute-based plugins to the Plugin API docs.
Added attribute discover to Drupal Plugin discovery
Remaining tasks
What else?
Comments
Comment #2
xjmComment #3
berdirAdding this to the meta issue about the conversion (which I think would be a better parent for this, but don't want to just change that).
Comment #4
longwaveWe need to ensure we document the outcome of #3400458: AttributeClassDiscovery fails while trying to include non valid plugin class, as there are stricter rules for what can exist in the namespace for pure attribute discovery compared to annotations.
Comment #5
xjmComment #6
quietone commentedThere is an existing page for 'Drupal Plugin Discovery' which lists four methods, StaticDiscovery, HookDiscovery, AnnotatedClassDiscovery and YamlDiscovery. That seems like a suitable place to add 'Attribute discovery'. Would that work?
Comment #7
quietone commentedAdded a page for attribute plugins, which is basic and needs work, https://www.drupal.org/docs/drupal-apis/plugin-api/attribute-based-plugins
Comment #8
quietone commentedWhat more needs to be done here?
Comment #9
smustgrave commentedCan this be closed per #6?
Comment #10
longwaveI think we should extend the page to include "Using attributes in your own plugin type" similar to the annotations example at https://www.drupal.org/docs/drupal-apis/plugin-api/annotations-based-plu...
Comment #11
quietone commentedStarted the section, Using attributes in your own plugin type.
Comment #12
smustgrave commentedReviewing just the section mentioned in #11 change makes sense based on reviews of the attribute tickets.
But question on "Defining a plugin" section.
we've been requiring that for attributes so should optional be removed. Either way seemed out of scope for this ticket so maybe a follow up.
Comment #13
catchThe deriver class is optional, the key is not.
Comment #14
quietone commentedI added another page, Create a custom attribute class. And that states that the deriver key is required in the Attribute class.
Comment #15
catchI think this is good progress, and we can refine it as time goes on. Eventually we'll need to deprecate and retire the annotations documentation but need to deprecate annotations first and that's still quite far off.