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

Command icon 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

valthebald created an issue. See original summary.

abramm’s picture

That'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.

valthebald’s picture

Status: Active » Needs review
valthebald’s picture

Status: Needs review » Needs work

Back to needs work because I haven't tested the full flow import then export

valthebald’s picture

Status: Needs work » Needs review
abramm’s picture

Hi 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!

abramm’s picture

Issue tags: +LutskGCW24
erwangel’s picture

Thank 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.

valthebald’s picture

Updated the fork following the interface change in 1.4.5

vasike’s picture

Status: Needs review » Reviewed & tested by the community

It 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.

erwangel’s picture

I 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.

leeksoup’s picture

Can this also work for comment entities like the comment_forum fields that the Forum module uses? What else would need to be added?

leeksoup’s picture

Re #13, I tried it and it does not work for comments. (No export option is available for comments even with this patch installed.)

nginex’s picture

Assigned: Unassigned » nginex
nginex’s picture

Comments export and import will be handled in a separate issue #3478941: creating a comment exporter plugin as it has different structure and relationship

nginex’s picture

Assigned: nginex » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks for the contribution, it's a nice improvement, I will commit it as first iteration with possible improvements in the future

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.