- Issue created by @mlncn
Hi, do you mean something like this? https://git.drupalcode.org/project/changed_fields/-/blob/8.x-3.x/tests/s...
- 🇺🇸United States mlncn Minneapolis, MN, USA
Thank you!
Not quite, i am looking to track that say "Text 1" in that test is the same even if "Text 2" were added as a second value in the multivalue field and even if the "Text 1" value switched position from delta 0 to delta 1.
Kind of crazy, i know, with the way Drupal works but i think i could do it all right with hashing to compare longer values.
I'll be building on Changed Fields anyway i think, do you imagine any of this granular value-by-value comparison would make sense to be part of Changed Fields or a submodule?
- 🇺🇸United States mlncn Minneapolis, MN, USA
argh, to build on it
getComparableProperties()
in Drupal\changed_fields\FieldComparatorPluginManager available through theplugin.manager.changed_fields.field_comparator
would have to be a public function or otherwise available.Would you accept a merge request for that field?
(Module in-progress for what i discussed here is at https://www.drupal.org/project/value_revisions → )
Hi, sorry for the delay.
Not quite, i am looking to track that say "Text 1" in that test is the same even if "Text 2" were added as a second value in the multivalue field and even if the "Text 1" value switched position from delta 0 to delta 1.
So, basically, you want the rule like
values are the same if only values are the same regardless of their positions in multi values fields
?Sounds like you could implement an extended field comparator service and implement any rule you need by overriding
DefaultFieldComparator::compareFieldValues
method, like sort values somehow as you need and only then runcompareFieldValues
from the parent, something like that. Unless I totally misunderstood the whole idea.argh, to build on it getComparableProperties() in Drupal\changed_fields\FieldComparatorPluginManager available through the plugin.manager.changed_fields.field_comparator would have to be a public function or otherwise available.
getComparableProperties
is only used for defining what properties to look for in a given field definition. If you need to add support for a custom field then you need to implementgetDefaultComparableProperties
and look for field type there and return an array of custom properties. If you need to alter/extend the list of comparable properties of supported field types then I think you could implementextendComparableProperties
method in your extended field comparator and do whatever you need there. It's basically called fromgetComparableProperties
here.- 🇺🇸United States mlncn Minneapolis, MN, USA
Thank you so much for the response— i think what you say makes sense, but i would twist my brain in knots if i were to try to re-follow, too soon, all the logic i implemented in Field Value Revisions → to see if i could refactor that module to build on top of Changed Fields API. I did steal getComparableProperties() and it is very useful, and Field Value Revisions does work!! I'll open an issue there about re-factoring on top of Changed Fields— for each value i'd need removed, added, stayed the same and the current delta of each (that might be the dealbreaker?). I think— it was quite the journey and i lack the brain or budget to re-take it right now. If it turns out i really cannot build on Changed Fields for some reason, i'll open an issue about any changes needed so that it could, or about a way to share the comparable properties logic.
Thank you again!
Automatically closed - issue fixed for 2 weeks with no activity.