Export works but import fails on custom entity

Created on 28 August 2024, 4 months ago

Problem/Motivation

I am trying to sync some course content made using ANU LMS module. I followed the steps from the README file:

### Can I extend exporting of my custom entity type?

Yes! You can implement a new `SingleContentSyncBaseFieldsProcessor` plugin to support your custom entity.

Check a few examples of existing plugins at `src/Plugin/SingleContentSyncBaseFieldsProcessor`.

I created a plugin (attached) to support the "assessment_question" entity from ANU LMS and the export works fine. But when I go to import it, I get an error saying:

Exception: "assessment_question" does not have entity field base processor defined. in Drupal\single_content_sync\ContentImporter->importBaseValues() (line 267 of /path/to/web/modules/contrib/single_content_sync/src/ContentImporter.php).

Steps to reproduce

  1. Install ANU LMS and create a couple of lessons that includes an assessment question (long text response).
  2. Export the lessons.
  3. Import the generated zip file.

Proposed resolution

How can I fix the problem? I looked in the README but all it says is:

### Can I extend importing of my custom entity?

In most cases, new entity types would be handled automatically. Similar to exporting, there's an `ImportEvent` which
could be subscribed to alter the imported entity before it's saved.

Is there anything more than just the plugin file that I need to add?
Thanks.

πŸ’¬ Support request
Status

Closed: works as designed

Version

1.4

Component

Code

Created by

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

Comments & Activities

  • Issue created by @leeksoup
  • Status changed to Postponed: needs info 4 months ago
  • πŸ‡ΊπŸ‡¦Ukraine nginex

    @leeksoup I checked your code and here is my notes:

    1. If you implement this plugin in your custom module, can you please change your namespace, currently you are using (it must contain your module name, not the contrib module name)

    namespace Drupal\single_content_sync\Plugin\SingleContentSyncBaseFieldsProcessor;

    2. Your class name "assessment_question" does not follow any standards, could you please follow naming pattern e.g. AssessmentQuestion

    Could you please try it, clear cache and let me know if it works

  • Status changed to Closed: works as designed 4 months ago
  • Thank you for the quick response! I will fix those items.

    Nvm, it's my fault. I forgot to add my custom plugin to the site where I was importing the content. :facepalm: When I fixed that, it all imported fine. Nice work on the module!

    Apologies! ... and I'll close this issue.

  • πŸ‡ΊπŸ‡¦Ukraine nginex

    Thanks, nice that you figured this out

Production build 0.71.5 2024