drupal-code-generator
drupal-code-generator copied to clipboard
Update plugin generators to use PHP attributes
Drupal now supports plugin discovery through PHP attributes. https://www.drupal.org/project/drupal/issues/3252386
DCG generators needs to be updated to support this feature.
The main question is how implement this without breaking compatibility with Drupal 10.1.
Option 1 Add CLI option or question to each plugin generator to ask a user explicitely whether the plugin should use attributes instead of annotations.
Downside: A lot of work. Each plugin template will have if statements to support both types of discovery. Testing double implementation would be a nightmare.
Option 2
Use PHP attributes by default and convert them into annotations magically using AssetPreProcess event if Drupal version is below 10.2.
Downside: Testing is still hard.
Option 3 Release new DCG version (3.4) that only supports Drupal 10.2 and above. Keep DCG 3.3 as LTS release till Drupal 10.1 is EOL.
Option 4 Do nothing. Just wait for Drupal 10.1 EOL (June, 2024) before starting work on this.
I think you need to get rid of old way in separate branch and just throw error if core is incompatible
surely drush should align as well
I think the option 3 but with 4.0 release
also depending on version you can use templates vs templates_attributes directory
Looks like we are cruising along toward Option 4?
Plugin generators will be updated in DCG 4.x. See #156 for details.