You are here

public function ContentImportTrait::generateImportBatch in Content Synchronization 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Form/ContentImportTrait.php \Drupal\content_sync\Form\ContentImportTrait::generateImportBatch()

Parameters

$content_to_sync:

$content_to_delete:

$serializer_context:

content_sync_directory: path for the content sync directory.

Return value

array

2 calls to ContentImportTrait::generateImportBatch()
ContentSync::submitForm in src/Form/ContentSync.php
Form submission handler.
ContentSyncCommands::import in src/Commands/ContentSyncCommands.php
Import content from a content directory.

File

src/Form/ContentImportTrait.php, line 32

Class

ContentImportTrait
Defines the content import form.

Namespace

Drupal\content_sync\Form

Code

public function generateImportBatch($content_to_sync, $content_to_delete, $serializer_context = []) {
  $serializer_context['content_sync_directory_entities'] = content_sync_get_content_directory('sync') . "/entities";
  $serializer_context['content_sync_directory_files'] = content_sync_get_content_directory('sync') . "/files";
  $operations[] = [
    [
      $this,
      'deleteContent',
    ],
    [
      $content_to_delete,
      $serializer_context,
    ],
  ];
  $operations[] = [
    [
      $this,
      'syncContent',
    ],
    [
      $content_to_sync,
      $serializer_context,
    ],
  ];
  $batch = [
    'title' => $this
      ->t('Synchronizing Content...'),
    'message' => $this
      ->t('Synchronizing Content...'),
    'operations' => $operations,
  ];
  return $batch;
}