GatherContent recently added Components as a new field type: https://gathercontent.com/components-release These work similarly to Drupal Paragraphs, where you can build a repeatable content structure with multiple fields, then include them as part of a content item.
I built out a test template in GatherContent that includes a couple components, then in Drupal, tried to create a mapping for it. When I did, I received this error:
Notice: Undefined index: component in Cheppers\GatherContent\DataTypes\Group->Cheppers\GatherContent\DataTypes\{closure}() (line 43 of /var/www/html/vendor/cheppers/gathercontent-client/src/DataTypes/Group.php)
Are there plans to add support for components? I think it'd be useful for sites that use Paragraphs or Layout Builder with blocks, though I am wondering how the structure within GatherContent might affect import capabilities (in most sites I work on, I have a Content field that allows for multiple Paragraphs of different types, and GatherContent doesn't quite match that as far as I can tell, since you add the Paragraphs directly to the content item, not all contained as part of a single field).
Thanks!
Comment | File | Size | Author |
---|---|---|---|
#12 | 3245330-interdiff-10-12.txt | 7.32 KB | mathilde_dumond |
#12 | 3245330-12.patch | 10.28 KB | mathilde_dumond |
#10 | 3245330-interdiff-7-10.txt | 6.95 KB | mathilde_dumond |
#10 | 3245330-10.patch | 13.33 KB | mathilde_dumond |
#7 | 3245330-7.patch | 9.07 KB | mathilde_dumond |
Comments
Comment #2
Toby Wild CreditAttribution: Toby Wild commentedYeh, this would be massively useful.
Any plans?
Comment #3
mathilde_dumond CreditAttribution: mathilde_dumond at MD Systems GmbH commentedStarted that, with the assumption that we flatten the components.
It depends on the patch and new client introduced here https://www.drupal.org/project/gathercontent/issues/3315895
Comment #4
mathilde_dumond CreditAttribution: mathilde_dumond at MD Systems GmbH commentedComment #5
mathilde_dumond CreditAttribution: mathilde_dumond at MD Systems GmbH commentedrelated pull request for the client: https://github.com/gathercontent/gathercontent-php-client/pull/4
Comment #6
Berdirspace after :, I'd also suggest to do this as t('@component: @label') or so, that allows to "translate" it to rtl languages.
Comment #7
mathilde_dumond CreditAttribution: mathilde_dumond at MD Systems GmbH commentedComment #8
mathilde_dumond CreditAttribution: mathilde_dumond at MD Systems GmbH commentedComment #9
Berdirthis is a strange mix of a function (snake_case) and a method (camelCase).
If we keep it as a function, it should be snake_case, but the goal for most code should be to be in a class, unless it's a hook or so.
That's a bit tricky as we use it in multiple places. There are two options:
* We add it as a public static function on e.g. MappingSteps.
* We add it as a trait that we use in both places.
a trait is slightly cleaner but also a bit more work/code.
notes on coding standards/style:
* empty line between params and return
* use explict array type for parameter and the return type:
(array $fields): array
* for the the @param and @return, you can define it as list of element classes with ...\Element[]
then, naming. You use 3 different concepts now for this (fields, item and component), that should all be the same. children is ok as it's generic.
They call those classes Elements, so I would go with that, so that would be $elements as parameter, then elements as element foreach, then $children and $child_element. and the function/method name then also uses flattenGroup, that too should be either flattenFields or Elements.
Update: I did just read below that suddenly they call them fields there as well. So it's also OK to go with fields, as long as it's consistent.
the description should also explain a bit more what the different between the two is.
instanceof.
It should be continue (proceed with next item in array), not return.
missing docblock.
a bit confused why $group_id here is optional, it won't do or return anything then?
the call above does not check if the function returns something or not, either it must always return something (add a return type then to enforce that) or not, but then the caller needs to support that.
this is an existing replacement, are you sure that's correct?
are we sure that there are no existing things that use this structure?
Comment #10
mathilde_dumond CreditAttribution: mathilde_dumond at MD Systems GmbH commentedThanks for your feedback :)
I addressed most of it:
1. I could not put this function in MappingSteps, because it is used in MappingEditForm. I moved it to a trait.
5: my reasoning was that I thought that it would be nice to not depend on group_id, but it was simpler to just rely on it, and I did not go to the next step of writing a version without group_id, since I did not need it. I removed the optionality.
6: removed that, thanks
7: this led to duplication after my changes in getFieldValue
Comment #11
Berdirthis is just the namespace use, you need to use it in the classes as well, see traits in base class for example.
there are also more classes that call it. I'd suggest putting it in base classes if possible.
(if you would make it public static you could have accessed it from other classes too, but trait is ok too)
namespace and location does not match. also not sure if this should be in ui module, it's only used there.
Comment #12
mathilde_dumond CreditAttribution: mathilde_dumond at MD Systems GmbH commentedFixed that, and also removed the patch from the patch :D
Comment #14
BerdirCommitted.