Closed (fixed)
Project:
GatherContent
Version:
6.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
15 May 2020 at 10:48 UTC
Updated:
28 Oct 2022 at 14:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
Kova101 commentedThis feature is in development for 8.x-5.x alongside with a refactored paragraph implementation.
Currently we did not plan to implement it into the 8.x-4.x but we will think about it.
Comment #3
Kova101 commentedComment #4
mathilde_dumond commentedI added support for media reference field (not for paragraphs)
Comment #5
berdirlooks like you included the other patch in your diff.
all of them :)
use reset(), that will return the first element in the array without changing it like array_shift() does.
Also, above here is the bug we discussed with the auto-create. You must check if auto-create is enabled before using the auto-create bundle setting. Basically duplicate \Drupal\Core\Field\Plugin\Field\FieldWidget\EntityReferenceAutocompleteWidget::getAutocreateBundle(). as you can see there, unfortunately the setting really is only used if there is more than one enabled bundle, with just one, it's likely wrong.
make sure you really get a field back from that first call, that's not guaranteed, it can return null.
Also, I do wonder if we should loop over the enabled bundles instead of just picking the first like taxonomy, because you can't really control the order. then we'd use the first compatible type, not just the first and fail if that doesn't work.
that would mean duplicating the bundle selection logic for taxonomy and media. for media, we'd still respect the auto-create setting if enabled, but if not, we'd loop over them, so always make it an array and this would be a continue instead of a break, the break would be when we found one.
the process plugin should have config schema, but the existing ones don't have that either. See migrate_plus.process.schema.yml for examples.
ok, so the big topic now is reusing of files/media.
I'm pretty sure, but first, can you confirm my assumption that every time you import, it creates duplicate files and medias?
It uses file_save_data() internally which defaults to FileSystemInterface::EXISTS_RENAME, so you should see the usual _0, _1 files and so on pop up as well as duplicates in the media list.
Lets have a look at that together and discuss this, that should be easier.
this is a bit of a mix of single and multi-support now.
If you are going for a loop and supporting multiple values, don't bother with first id. Just return a list of $result, it's field values, so you can just return multiple and it should work fine.
there is no such thing as an image file, only an image filed.
The structure:
host entity -> entity reference field -> media entity -> image/file field -> file entity.
a bit concerned that we can't rely on the keys. if you look at downloadFiles(), it calls array_values() on it. I'm unsure why it does that, I would expect that they are numbered keys, no?
Comment #6
mathilde_dumond commentedSo, here is a new version of this patch:
1 &2: hopefully there is nothing left anymore
3: used reset, and fixed the auto generate bundle thing
4: I am not sure that I do the existence check too late?
5: added a schema
6&7. Multiple media work. However, multiple files do not work, and I do not know yet why
9. I am not sure. I am confused about the downloadFiles function, and how the order of the files is. they call a ksort at some poitn so I guess they get shuffled at some point?
Comment #7
mathilde_dumond commentedNow with the small improvement that because we don't support multiple values in the file and media plugin, we do not need to support these cases.
Comment #8
berdirComment #10
berdirCommitted.