You are here

protected function ImportCommand::importChunks in Tome 8

Imports chunks of content using sub-processes.

Parameters

array $chunks: An array of arrays of strings.

int $entity_count: The number of entities to import per process.

int $process_count: The number of processes to invoke concurrently.

Return value

bool Whether or not the import completed successful.

2 calls to ImportCommand::importChunks()
ImportCommand::execute in modules/tome_sync/src/Commands/ImportCommand.php
ImportPartialCommand::execute in modules/tome_sync/src/Commands/ImportPartialCommand.php

File

modules/tome_sync/src/Commands/ImportCommand.php, line 165

Class

ImportCommand
Contains the tome:import command.

Namespace

Drupal\tome_sync\Commands

Code

protected function importChunks(array $chunks, $entity_count, $process_count) {
  foreach ($chunks as $chunk) {
    if (empty($chunk)) {
      continue;
    }
    $commands = [];
    foreach (array_chunk($chunk, $entity_count) as $names) {
      $commands[] = $this->executable . ' tome:import-content ' . escapeshellarg(implode(',', $names));
    }
    $collected_errors = $this
      ->runCommands($commands, $process_count, 0);
    if (!empty($collected_errors)) {
      $this
        ->io()
        ->error('Errors encountered when importing content:');
      $this
        ->displayErrors($collected_errors);
      return FALSE;
    }
  }
  return TRUE;
}