Skip to content
This repository has been archived by the owner on Jun 21, 2020. It is now read-only.
/ content_sync Public archive

Drupal 8 module for exporting and importing menu items and taxonomy terms. Companion module to https://www.drupal.org/project/defaultcontent

Notifications You must be signed in to change notification settings

wfp/content_sync

Repository files navigation

Sync Data

Module for exporting and importing menu items and taxonomy terms etc. You can import/export any type of entities using this module but filtering capabilities during export is implemented only for menu_link_content & taxonomy_term entities.

This module exposes Drupal Console commands. There is nothing configurable from the UI.

Installation

Install it as any other Drupal module - Installing contributed modules (Drupal 8)

This module depends on Default Content version 1.0-alpha5.

Export

drupal content_sync:export - This is for all types of entities, it's an interactive wizard which will ask you to input entity type from suggested list of entities.

Export Menu Items

If you choose menu_link_content from suggested entity types you will get list of menus from which you will chose the menu you want to export. After you choose menu you have to input module name in which content will be exported. Thats it, you will find exported JSON files in specified module - modules/custom/{module_name}/content/

NOTE: this exports only menu items, not menu itself, you have to export/import menu using Configuration Manager.

Export Taxonomy Terms

If you choose taxonomy_term from suggested entity types you will get list of vocabularies from which you will choose the vocabulary you want to export. After you choose vocabulary you have to input module name in which content will be exported.

That's it, you will find exported JSON files in specified module - modules/custom/{module_name}/content/.

Options for basic export:

  • content_type - entity type id (machine name) of an entity you want to export.
  • module - Module machine name to which content will be exported.

Options for menu items export:

  • content_type - entity type id - menu_link_content.
  • module - Module machine name to which content will be exported.
  • menu_name - name of the menu.

Options for menu taxonomy terms export:

  • content_type - entity type id - taxonomy_term.
  • module - Module machine name to which content will be exported.
  • vid - Vocabulary id

NOTE: this only exports Taxonomy terms as vocabularies are handled by CM in core.

Import

drupal content_sync:import - This will import any type of entities generated in JSON format using drupal content_sync:export, it will ask module name from which content will be imported. It is expected that JSON files are stored in content/{entity_type_id} folder under module.

Options for importing:

  • folder - path to the content folder (e.g. path/to/module/root/content).

NOTE:

It will try to import any JSON file found int content folder, so be careful and think what you want to achieve.

E.g. if you want to import menu items make sure that menu is already empty to prevent conflicting uuids.

Clearing commands

There are 2 clearing commands implemented for now:

  • drupal content_sync:vocabulary-clear
  • drupal content_sync:clear-menu

Development Tools

Install

composer install

Usage

# PHP Code standards audit (Coder, DrupalStrict, etc.)
composer run phpcs

# PHP Copy-paste detection
composer run phpcpd

# Run all code audits
composer run audit

About

Drupal 8 module for exporting and importing menu items and taxonomy terms. Companion module to https://www.drupal.org/project/defaultcontent

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages