Depends on #1969728: Implement Field API "field types" as TypedData Plugins

All core field types have to be converted to typed data plugins.

Ongoing work happens in core-modules-field-types-datatypes-2014671 based on field-types-as-datatypes-1969728 from the sandbox (http://drupalcode.org/sandbox/yched/1736366.git)

#2015703: Convert field type to typed data plugin for email module - commit
#2015701: Convert field type to typed data plugin for entity reference module
#2015697: Convert field type to typed data plugin for file and image modules
#2017139: Convert field type to typed data plugin for datetime module (has patch - but dates don't save for now)
#2015695: Convert field type to typed data plugin for image module
#2015693: Convert field type to typed data plugin for link module - commit
#2015691: Convert field type to typed data plugin for number module - commit
#2015689: Convert field type to typed data plugin for options module
#2015687: Convert field type to FieldType plugin for taxonomy module
#2015683: Convert field type to typed data plugin for telephone module - commit
#2083803: Convert field type to typed data plugin for field_test module
#2087381: Decouple EmailItem field class from LegacyFieldItem
#2087393: Remove LegacyField once all field types converted.

How to convert

  1. Move the existing FieldItem class for the field type into the right folder for plugin discovery.
  2. Make it extend ConfigFieldItemBase instead of LegacyConfigFieldItem.
  3. Move the hook_field_info() entries in annotations.
  4. Move the various "hook_field_*()" implementations to methods as per the mapping in the issue summary in #1969728: Implement Field API "field types" as TypedData Plugins.

For a simple example see the conversion of the telephone module: http://drupalcode.org/sandbox/yched/1736366.git/commitdiff/d2fb7014a9f5b... (needs update though for ConfigFieldItemBase)

Comments

swentel’s picture

Issue tags: +Field API

Tagging, let's hope we can crowdsource this a little

swentel’s picture

Title: Convert all field types to data type plugins » [META] Convert all field types to data type plugins

Changing to meta, I'll add the links to separate issues in a minute, we can use this one to list instructions etc.

swentel’s picture

Issue summary: View changes

Updated issue summary.

swentel’s picture

Note, started a new branch based on field-types-as-datatypes-1969728 - I'll slowly start implementing a few 'easy' modules and one hard one to start battle testing the API so we get a bit up to speed. I'll merge from the field types branch all the time.

yched’s picture

Yay, great idea !

Off the top of my head (can't look at code right now), the tasks to convert a field type are:
- move the existing FieldItem class for the field type into the right folder for plugin discovery
- make it extend CFieldItemBase instead of LegacyCFieldItem
- move the hook_field_info() entries in annotations
- move the various "hook_field_*()" implementations to methods as per the mapping in the issue summary in #1969728: Implement Field API "field types" as TypedData Plugins

And agreed, ideally, after the correct steps have been validated on a simple field type, the rest would be better off crowdsourced.

Note: this should start with a field type that doesn't implement hook_field_prepare_view(), since this one is not ported yet.

swentel’s picture

I'll update this evening - edit updated issue summary

Did a little test with the telephone module, works nice locally

see http://drupalcode.org/sandbox/yched/1736366.git/commitdiff/d2fb7014a9f5b...

swentel’s picture

Issue summary: View changes

Updated issue summary.

swentel’s picture

Issue summary: View changes

Updated issue summary.

swentel’s picture

Issue summary: View changes

Updated issue summary.

swentel’s picture

Issue summary: View changes

Updated issue summary.

swentel’s picture

Issue summary: View changes

Updated issue summary

swentel’s picture

So email, link, number and telephone are done (although I'm not sure if number is totally ok - see commit links in the summary). Those were the easy ones :)

Going to take on taxonomy and entity reference tomorrow, I suspect the latter one to become interesting :)

yched’s picture

w00t !

although I'm not sure if number is totally ok

Nothing strikes me on a quick read of the commitdiff - do you have specific concerns in mind ?

entity_reference & taxo might be better off waiting for #1965208: Convert TaxonomyTermReferenceItem to extend EntityReferenceItem.
There's also #1996714: Convert FileItem and ImageItem to extend EntityReferenceItem for image / file fields.
In the end, we'll probably want something like:
TaxoItem extends EntityRefItem
ImageItem extends FileItem extends EntityRefItem
but things should be easier after those two patches land.

swentel’s picture

do you have specific concerns in mind

I just forgot to rerun the number field item test which had a fail, but the field api number field is green. So no biggie :)

Good to know re: entity reference, I'll target another one :)

swentel’s picture

Issue summary: View changes

Updated issue summary.

swentel’s picture

Issue summary: View changes

Updated issue summary.

swentel’s picture

Status: Postponed » Active

We can start on this, oh dear.

swentel’s picture

Issue summary: View changes

Updated issue summary.

swentel’s picture

Issue summary: View changes

Updated issue summary.

pfrenssen’s picture

Issue summary: View changes

Fully spelled out LegacyConfigFieldItem. Formatted list.

fago’s picture

Title: [META] Convert all field types to data type plugins » [META] Convert all field types to plugins

I think we can re-name this one though, as they are exposed as data type plugins by becoming field type plugins :-)

andypost’s picture

Berdir’s picture

Priority: Normal » Critical

I guess this one is critical, so that we can afterwards clean this up and remove the legacy layer and entity BC decorator usage.

yched’s picture

@Berdir: I'm not sure the "field type" BC layer requires the entity BC decorator to keep working.

Berdir’s picture

Possibly not, what I meant is that the current Field "dispatch" code has BC support into both directions, beside legacy field types, it also supports (doesn't require) BC entities, something that's no longer necessary because all fieldable entity types were converted. And I thought it would be easier to clean that up together but maybe not :)

Berdir’s picture

Issue summary: View changes

Typo.

Berdir’s picture

Added #2083803: Convert field type to typed data plugin for field_test module to the list, looks like that was forgotten?

Berdir’s picture

Issue summary: View changes

Updated issue summary.

catch’s picture

catch’s picture

Issue summary: View changes

Updated issue summary.