Skip to content
Snippets Groups Projects

Issue #3462551: Add option to export everything

Merged Zoltan Attila Horvath requested to merge issue/eme-3462551:3462551-option-to-export into 2.x
Files
10
+ 28
23
@@ -158,6 +158,8 @@ class EmeCommands extends DrushCommands {
* The ID of the export plugin to use.
* @option use-batch
* Use Drupal batch.
* @option all
* Export every content entity and their dependencies.
*
* @usage eme:export --id demo --types node,block_content
* Export all custom blocks, nodes and their dependencies to a new module at
@@ -186,6 +188,7 @@ class EmeCommands extends DrushCommands {
],
) {
$given_options = array_filter($options);
$exportEverything = array_key_exists('all', $given_options);
$types_to_export = !empty($given_options['types'])
? array_filter(explode(',', $given_options['types']))
: NULL;
@@ -199,14 +202,14 @@ class EmeCommands extends DrushCommands {
? trim($given_options['destination'], '/')
: 'modules/custom';
// Update does not allows override anything but the exported entity types.
// Update does not allow override anything but the exported entity types.
if ($options['update']) {
if (!array_key_exists($options['update'], $this->discoveredExports)) {
$this->logger()->error(dt('The specified export module does not exist.'));
return;
}
$module_name = $options['update'];
// Update does not allows override anything but the exported entity types.
// Update does not allow override anything but the exported entity types.
$types_to_export = $types_to_export ?? $this->discoveredExports[$module_name]['types'];
[
'name' => $human_name,
@@ -225,26 +228,28 @@ class EmeCommands extends DrushCommands {
}
// Validate entity type IDs.
if (empty($types_to_export) || !is_array($types_to_export)) {
$this->logger()->error(dt('No entity types were provided.'));
return;
}
$missing_mistyped_ignored = array_reduce(
$types_to_export,
function (array $carry, string $entity_type_id) {
$pieces = explode(':', $entity_type_id);
if (!isset($this->contentEntityTypes[$pieces[0]])) {
$carry[] = $entity_type_id;
}
return $carry;
},
[]
);
if (!empty($missing_mistyped_ignored)) {
$this->logger()->error(dt('The following entity type IDs cannot be found or are set to be ignored during content export: @entity-types.', [
'@entity-types' => implode(', ', $missing_mistyped_ignored),
]));
return;
if (!$exportEverything && $types_to_export !== 'all') {
if (empty($types_to_export) || !is_array($types_to_export)) {
$this->logger()->error(dt('No entity types were provided.'));
return;
}
$missing_mistyped_ignored = array_reduce(
$types_to_export,
function (array $carry, string $entity_type_id) {
$pieces = explode(':', $entity_type_id);
if (!isset($this->contentEntityTypes[$pieces[0]])) {
$carry[] = $entity_type_id;
}
return $carry;
},
[]
);
if (!empty($missing_mistyped_ignored)) {
$this->logger()->error(dt('The following entity type IDs cannot be found or are set to be ignored during content export: @entity-types.', [
'@entity-types' => implode(', ', $missing_mistyped_ignored),
]));
return;
}
}
// Validate export destination.
@@ -262,7 +267,7 @@ class EmeCommands extends DrushCommands {
}
$export_config = [
'types' => $types_to_export,
'types' => $types_to_export ?: 'all',
'module' => $module_name,
'name' => $human_name,
'id-prefix' => $migration_prefix,
Loading