Create default plugin for content entities

Created on 15 January 2024, 11 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

Active

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 11 months ago
  • πŸ‡§πŸ‡¬Bulgaria valthebald Sofia
  • Pipeline finished with Success
    11 months ago
    Total: 177s
    #77941
  • Status changed to Needs work 11 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 11 months ago
  • πŸ‡§πŸ‡¬Bulgaria valthebald Sofia
  • Pipeline finished with Success
    11 months ago
    Total: 213s
    #77999
  • Pipeline finished with Canceled
    11 months ago
    #78095
  • Pipeline finished with Failed
    11 months ago
    Total: 176s
    #78096
  • Pipeline finished with Success
    11 months ago
    Total: 175s
    #78097
  • Pipeline finished with Success
    11 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
    11 months ago
    Total: 215s
    #84148
  • Pipeline finished with Success
    11 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.

  • Pipeline finished with Canceled
    5 months ago
    Total: 98s
    #244536
  • Pipeline finished with Success
    5 months ago
    Total: 193s
    #244537
  • πŸ‡§πŸ‡¬Bulgaria valthebald Sofia

    Updated the fork following the interface change in 1.4.5

  • πŸ‡·πŸ‡΄Romania vasike Ramnicu Valcea

    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.

  • πŸ‡«πŸ‡·France erwangel

    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.

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

  • Status changed to RTBC 3 months ago
  • Re #13, I tried it and it does not work for comments. (No export option is available for comments even with this path installed.)

  • πŸ‡ΊπŸ‡¦Ukraine nginex
  • πŸ‡ΊπŸ‡¦Ukraine nginex

    Comments export and import will be handled in a separate issue πŸ’¬ creating a comment exporter plugin Active as it has different structure and relationship

  • πŸ‡ΊπŸ‡¦Ukraine nginex

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

  • Status changed to Fixed 4 days ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024