drupal-code-generator icon indicating copy to clipboard operation
drupal-code-generator copied to clipboard

Update plugin generators to use PHP attributes

Open Chi-teck opened this issue 2 years ago • 4 comments

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.

Chi-teck avatar Oct 28 '23 05:10 Chi-teck

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

andypost avatar Oct 28 '23 12:10 andypost

I think the option 3 but with 4.0 release

andypost avatar Oct 28 '23 12:10 andypost

also depending on version you can use templates vs templates_attributes directory

andypost avatar Oct 28 '23 12:10 andypost

Looks like we are cruising along toward Option 4?

weitzman avatar Mar 04 '24 21:03 weitzman

Plugin generators will be updated in DCG 4.x. See #156 for details.

Chi-teck avatar May 21 '24 17:05 Chi-teck