Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294263

Fix sub-optimal DX in MigrateFieldInterface

$
0
0

Problem/Motivation

Some of Migrate’s cckfield plugin's method naming are not describing clear enough what they do and therefore may confuse developers using the API (therefore giving poor DX).

Proposed resolution

See discussion in #23 - #27

  • Rename processFieldValues() to defineValueProcessPipeline()
  • Rename processField() to alterFieldMigration()/li>
  • Rename processFieldInstance() to alterFieldInstanceMigration()
  • Rename processFieldWidget() to alterFieldWidgetMigration()
  • Rename processFieldFormatter() to alterFieldFormatterMigration()
  • Update tests
  • Add BC layer

Remaining tasks

Review
Commit

User interface changes

None.

API changes

Yes.

  1. processCckFieldValues()will be deprecatedThis wad deprecated in #2683435: CCK does not exist in Drupal 7, rename Migrate's cckfield plugins to field plugins
  2. processFieldValues() will be deprecated
  3. processField() will be deprecated
  4. processFieldInstance() will be deprecated
  5. processFieldWidget() will be deprecated
  6. processFieldFormatter() will be deprecated

Data model changes

None.

Original report

Those who know me know that I’m fairly fanatical about good DX in core APIs (or, indeed, any APIs). Because of that, certain aspects of Migrate’s cckfield plugins have been bugging me for a long time.

I have three main bones to pick:

  1. processField() is poorly named. Its actual purpose is altering the migrations that transform CCK fields (in D6) and Field API field definitions (in D7) into D8 field_storage_config entities. This should be renamed to processFieldMigration() or alterFieldMigration().
  2. processFieldInstance() has the same problem. It should be called processFieldInstanceMigration() or alterFieldInstanceMigration().
  3. processCckFieldValues() is on another planet entirely. Its purpose is to define the processing pipeline for values of the field type that the plugin handles, but this does not come through at all in the method name. I think this should be called something like defineFieldValueProcess() or defineValueProcessPipline().

The doc blocks for each of these methods in MigrateCckFieldInterface need to be improved as well. These plugins are crucial for contrib migrations from D6 and D7, so the interface should include short snippets of example code in the doc comments.


Viewing all articles
Browse latest Browse all 294263

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>