Closed (fixed)
Project:
Field Formatter Class
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
14 Apr 2021 at 11:09 UTC
Updated:
21 Nov 2022 at 16:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
n4r3nComment #3
n4r3nComment #4
huzookaThe 'Configuration' tag has to be added here.
Now this is completely unused.
Imho this should extend
Drupal\migrate\Plugin\migrate\destination\PerComponentEntityDisplay.Almost everything is there.
If
MigrateDestinationInterface::import()returns booleans, then it means that no mapping is saved. I don't think we want this.It is always better to allow the ID map plugin to save a mapping record.
This is definitely wrong: this means that every processed Row with the same
'id'represents the same thing.(BTW what this 'id' stands for?)
Check how this looks in
Drupal\migrate\Plugin\migrate\destination\ComponentEntityDisplayBase: entity type ID, bundle, field name and view mode.(Obviously this is not an issue until the previous above is fixed.)
We don't need this source plugin. The
d7_field_instance_per_view_modein core will unserialize the field instance settings for us,so instead of unserializing the data source property in the destination plugin, you will be able to apply proper process(es) in the migration plugin definition.
We'll also get the view_mode as source property. The field formatter class (if any) will be in
formatter/settings/field_formatter_class.If we want to be perfect, then we still can extend
FieldInstancePerViewMode, then we only have to add a condition to the parent query that explicitly filters for field config instance records havings:21:"field_formatter_class"in theirdatafield, or filter for this setting key in::initializeIterator().I would like to see a test case with multiple classes, and also an entity type which has at least two fields with
field_formatter_settingsapplied.Comment #5
wim leersThanks for the review, @huzooka! Back to you, @n4r3n 😊
Comment #6
n4r3nThanks for the review @huzooka... I've updated the patch here :) also uploading the interdiff.
I am still working on the testcases :)
Comment #7
wim leersGreat progress, @n4r3n — thanks, and looking forward to that patch with tests 🤓
Comment #8
n4r3nThanks @wim for helping with fixtures :) I've updated patch with tests. Also attaching interdiffs.
Comment #9
wim leersWhile we await a more thorough review from @huzooka, here's a superficial one to clean things up:
I think we want to get rid of the
echo $id🤓🤔 This should IMHO use the API instead of an array:
setThirdPartySetting().See
\Drupal\field_group_migrate\Plugin\migrate\destination\FieldGroupEntityViewDisplayfor an example.🤓 This is still a copy/paste leftover I think :)
🤓 Nit: missing inheritdoc.
🤓 Nit: indentation off.
Comment #10
japerryPretty sure support for using the API for components isn't supported yet, #3015152: Support third-party settings for components within a section
Comment #11
n4r3nUpdated the patch with clean ups :)
setThirdPartySetting()didn't work well with individual field components.Comment #12
huzookaRe #11:
Nice progress! 🙂
My last nits:
It's time to use process pipelines:
You should replace
[…]with the corresponding processes fromd7_field_formatter_settingsin core.Destination plugins should use
Row::getDestinationProperty()instead ofRow::get().What ensures that this does not return
NULL?You can leverage on the parent's
FieldInstancePerViewMode::initializeIterator()implementation, and do here something like this:Comment #13
n4r3nThanks @huzooka for the review, I've updated the patch.
Comment #14
wim leers#13: can you include an interdiff? 🤓 That makes reviewing changes between patches 100x easier! See https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa... for how to do that!
Also, can you please in the future change the issue status from to when you post a new patch? That's a way to signal to reviewers (i.e. mostly @huzooka here, since he's the primary reviewer — I'm only secondary here) that the patch is ready for the next round of review 😄
Comment #15
n4r3nThanks @wim for the guidance. Uploading interdiff here:
Comment #16
huzookaThis should be like in https://git.drupalcode.org/project/drupal/-/blob/9.1.8/core/modules/fiel...
See https://git.drupalcode.org/project/drupal/-/blob/9.0.13/core/modules/fie...
This makes the originally hidden fields visible. Are you sure we want this?
Comment #17
n4r3nThanks @huzooka, here I'm uploading updated patch and interdiff.
Comment #18
huzookaEntityDisplayBase::getComponent()returnsNULLin case of hidden components.In order not to make a hidden field be displayed, we shouldn't migrate field formatter class settings of hidden fields. You should change the line above and add something like this:
Comment #19
n4r3nThanks @huzooka, I've updated the patch :)
Comment #20
n4r3nUploading patch with interdiff:
Comment #21
huzookaThe code looks good! I also tested the patch in #20 in details, and it is working as expected!
These are my last nits, mostly about comments/annotations – but none of them are crucial!
The thrown exception should be specified with FQCN (
\Drupal\migrate\MigrateException).BTW, core has an empty line between
{@inheritdoc}and everything that follows it (seeDrupal\Core\Config\Entity\ConfigEntityType::checkStorageClass); let's do the same!This comment is misleading. Could we have something like "Migration source plugin for field formatter class settings." instead?
I think it would be nice to override the source count. Could you please add
Line is longer than 80 chars. Let's replace this with "Tests the migration of Drupal 7 field formatter class settings."
The test group annotation should use the module's machine name (that's why we cannot see this test executed by DrupalCI imho).
This should be
@group field_formatter_class.Line longer than 80 chars.
Please remove the condition (which wraps the assertions)!
It is completely unnecessary and risky.
Comment #22
n4r3nThanks again @huzooka, I've updated the patch :)
Comment #23
n4r3nComment #24
wim leersGreat — this is solid now!
Comment #25
chris matthews commentedAnyone here able to commit the patch in #22 plus #3287508: Automated Drupal 10 compatibility fixes and then tag a new D10 compatible release?
Comment #27
chris matthews commented