Problem/Motivation

In #3252386: Use PHP attributes instead of doctrine annotations we added support for attribute based plugin discovery.
As part of that issue we converted block and action plugins.

This issue is to convert \Drupal\Core\Field\Annotation\FieldType plugins to use Attributes.

Proposed resolution

  1. Add a class to represent the new Attribute - Example
  2. Update the plugin manager constructor to include both the attribute and annotation class names - example
  3. Convert all plugins that use the annotation to use the new attribute - example

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#15 3420981-nr-bot.txt90 bytesneeds-review-queue-bot

Issue fork drupal-3420981

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

larowlan created an issue. See original summary.

mstrelan’s picture

Title: Convert FieldType plugin discovery to attributes » [PP-1] Convert FieldType plugin discovery to attributes
Status: Active » Postponed
kim.pepper’s picture

Title: [PP-1] Convert FieldType plugin discovery to attributes » Convert FieldType plugin discovery to attributes
Status: Postponed » Active

kim.pepper’s picture

Status: Active » Needs review
mstrelan’s picture

Status: Needs review » Needs work

Can we update the docs for hook_field_info_alter in field.api.php here too? There are references to the annotation class but we should update to the attribute class.

kim.pepper’s picture

Status: Needs work » Needs review

#6 Done.

I was also questioning how these worked with Annotation\FieldType as they weren't defined anywhere I can see:

    public readonly array $config_dependencies = [],
    public readonly array $column_groups = [],
    public readonly array $serialized_property_names = [],
mstrelan’s picture

Status: Needs review » Needs work

#7 I think we can remove those. They are the additional keys mentioned at the top of the attribute/annotation class. Since the attribute values get converted to an array they don't need to be defined.

mstrelan’s picture

Actually I think if we need to remove them then we need an alter hook to add the values in.

berdir’s picture

What I'm doing in the entity type issue is add an explicit additional key where you can put it arbitrary settings.

But some of these we probably should define if they're part of the official API.

serialized property names is part of a security issue that went in a while ago, column_groups is afaik mostly used for content _translation, not sure about config dependencies. It's used in \Drupal\Tests\field\Kernel\TestItemWithDependenciesTest, would probably need to check the issue that added this to see what the real use cases are.

kim.pepper’s picture

Status: Needs work » Needs review

@Berdir #10 i had a look at #3396166: Convert entity type discovery to PHP attributes and doesn't look this you are doing this anymore?

I have left the properties in for now.

Re: config_dependencies I found this in the docs for \Drupal\Core\Config\Entity\ConfigDependencyManager

 * Classes for configurable plugins are a special case. They can either declare
 * their configuration dependencies using the calculateDependencies() method
 * described in the paragraph above, or if they have only static dependencies,
 * these can be declared using the 'config_dependencies' annotation key.
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Applied the MR searched for @FieldType all instances have been replaced
Verified $deriver is there (something had to check from previous attribute tickets)
Tests are all green, showing nothing broke.

Believe this is good

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
kim.pepper’s picture

Status: Needs work » Needs review

Addressed feedback so back to NR

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

quietone made their first commit to this issue’s fork.

quietone’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

All feedback appears to be addressed here.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed cf09596544 to 11.x and 4afc682d90 to 10.3.x. Thanks!

  • alexpott committed 4afc682d on 10.3.x
    Issue #3420981 by kim.pepper, quietone, mstrelan, Berdir, alexpott:...

  • alexpott committed cf095965 on 11.x
    Issue #3420981 by kim.pepper, quietone, mstrelan, Berdir, alexpott:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.