Create default plugin for content entities

Created on 15 January 2024, 5 months ago
Updated 2 March 2024, 4 months ago

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

✨ Feature request
Status

Needs review

Version

1.4

Component

Code

Created by

πŸ‡§πŸ‡¬Bulgaria valthebald Sofia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @valthebald
  • πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

    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.

  • Status changed to Needs review 5 months ago
  • πŸ‡§πŸ‡¬Bulgaria valthebald Sofia
  • Pipeline finished with Success
    5 months ago
    Total: 177s
    #77941
  • Status changed to Needs work 5 months ago
  • πŸ‡§πŸ‡¬Bulgaria valthebald Sofia

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

  • Status changed to Needs review 5 months ago
  • πŸ‡§πŸ‡¬Bulgaria valthebald Sofia
  • Pipeline finished with Success
    5 months ago
    Total: 213s
    #77999
  • Pipeline finished with Canceled
    5 months ago
    #78095
  • Pipeline finished with Failed
    5 months ago
    Total: 176s
    #78096
  • Pipeline finished with Success
    5 months ago
    Total: 175s
    #78097
  • Pipeline finished with Success
    5 months ago
    Total: 176s
    #79199
  • πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

    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!

  • πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk
  • Pipeline finished with Success
    5 months ago
    Total: 215s
    #84148
  • Pipeline finished with Success
    5 months ago
    Total: 176s
    #84197
  • πŸ‡«πŸ‡·France erwangel

    Thank you for this plugin which as it says aims to "reduce the need in custom plugins for each content type"! This MR-88 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.

Production build 0.69.0 2024