public function ContentExportTrait::generateExportBatch in Content Synchronization 8.2
Same name and namespace in other branches
- 3.0.x src/Form/ContentExportTrait.php \Drupal\content_sync\Form\ContentExportTrait::generateExportBatch()
Parameters
$entities:
$serializer_context: export_type: Tar -> YML to Tar file Snapshot -> YML to content_sync table. Directory -> YML to content_sync_directory_entities.
content_sync_directory_entities: path for the content sync directory.
content_sync_directory_files: path to store media/files.
content_sync_file_base_64: Include file as a data in the YAML.
Return value
array
3 calls to ContentExportTrait::generateExportBatch()
- ContentExportForm::snapshot in src/
Form/ ContentExportForm.php - ContentExportForm::submitForm in src/
Form/ ContentExportForm.php - Form submission handler.
- ContentSyncCommands::export in src/
Commands/ ContentSyncCommands.php - Export Drupal content to a directory.
File
- src/
Form/ ContentExportTrait.php, line 43
Class
- ContentExportTrait
- Defines the content export form.
Namespace
Drupal\content_sync\FormCode
public function generateExportBatch($entities, $serializer_context = []) {
$serializer_context['content_sync_directory_entities'] = content_sync_get_content_directory('sync') . "/entities";
if (isset($serializer_context['include_files'])) {
if ($serializer_context['include_files'] == 'folder') {
$serializer_context['content_sync_directory_files'] = content_sync_get_content_directory('sync') . "/files";
}
if ($serializer_context['include_files'] == 'base64') {
$serializer_context['content_sync_file_base_64'] = TRUE;
}
unset($serializer_context['include_files']);
}
//Set batch operations by entity type/bundle
$operations = [];
$operations[] = [
[
$this,
'generateSiteUUIDFile',
],
[
0 => $serializer_context,
],
];
foreach ($entities as $entity) {
$operations[] = [
[
$this,
'processContentExportFiles',
],
[
[
$entity,
],
$serializer_context,
],
];
}
//Set Batch
$batch = [
'operations' => $operations,
'title' => $this
->t('Exporting content'),
'init_message' => $this
->t('Starting content export.'),
'progress_message' => $this
->t('Completed @current step of @total.'),
'error_message' => $this
->t('Content export has encountered an error.'),
];
if (isset($serializer_context['export_type']) && $serializer_context['export_type'] == 'tar') {
$batch['finished'] = [
$this,
'finishContentExportBatch',
];
}
return $batch;
}