Problem/Motivation
ContentExporter::exportBaseValues() returns an empty array when there is no plugin for the exported entity. Since content entities derive from ContentEntityBase class and have its getBaseFieldDefinitions() method, having a plugin that handles generic content entities would reduce the need in custom plugins for each content type.
Steps to reproduce
Export an object of any unsupported out-of-the-box entity type => base fields section is empty.
Proposed resolution
Create new Drupal\single_content_sync\Plugin\SingleContentSyncBaseFieldsProcessor\ContentEntityBase plugin that will handle export of base fields of unsupported content entity types.
Fall back to this new plugin when exporting base fields.
Remaining tasks
Write the patch
Issue fork single_content_sync-3414711
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
abrammThat'd be a nice addition.
I would still ignore some field types though (like entity references) as they could be unsafe to import/export without special handling.
Comment #4
valthebaldComment #5
valthebaldBack to needs work because I haven't tested the full flow import then export
Comment #6
valthebaldComment #7
abrammHi valthebald,
I didn't test this yet but the code looks promising. We're going to work on the module issues at Global Contribution Weekend which is happening next week, will probably check it there.
Thank you for your effort!
Comment #8
abrammComment #9
erwangel commentedThank you for this plugin which as it says aims to "reduce the need in custom plugins for each content type"! This MR-88 (#8) applied and worked perfectly on D10.2.3 and SCS 1.4.4 for transferring feed entities (type feeds_feed). I just had to change the 'owner' field in the export yaml text ; this is hardcoded, to 'uid'. Perhaps you should set the default name of the entity owner to 'uid' that is more likely to meet than 'owner' or at least set a comment close to the corresponding line in yaml to attract user's attention that they may have to adjust the name of this field. I also had to move by hand the 'source' field which is of type 'uri' but this is rather a general issue, not this plugin's concern, as SCS lacks definition for 'uri' field in SingleContentSyncFieldProcessor.
Comment #10
valthebaldUpdated the fork following the interface change in 1.4.5
Comment #11
vasikeIt seems it helps a lot. I mark as RTBC as it seems to work and also to gain more attention on this very useful feature.
Maybe there could be improvements, but it will be easier to add, once it's part of the module.
Also for specific Custom entities ... if they are "very specific" ... of course Custom PLugins should be created.
Comment #12
erwangel commentedI agree with Vasike. I'm using this almost daily. Very useful to update nodes between development/stage/live sites, especially when one uses content nodes as landing pages with layout_builder and its settings accordingly.
Comment #13
leeksoup commentedCan this also work for comment entities like the comment_forum fields that the Forum module uses? What else would need to be added?
Comment #14
leeksoup commentedRe #13, I tried it and it does not work for comments. (No export option is available for comments even with this patch installed.)
Comment #15
nginex commentedComment #16
nginex commentedComments export and import will be handled in a separate issue #3478941: creating a comment exporter plugin as it has different structure and relationship
Comment #18
nginex commentedThanks for the contribution, it's a nice improvement, I will commit it as first iteration with possible improvements in the future