You are here

public function ImportService::importEntities in Entity Share 8.3

Plugin annotation

@SuppressWarnings(PHPMD . BooleanArgumentFlag);

Overrides ImportServiceInterface::importEntities

File

modules/entity_share_client/src/Service/ImportService.php, line 124

Class

ImportService
Class ImportService.

Namespace

Drupal\entity_share_client\Service

Code

public function importEntities(ImportContext $context, array $uuids, bool $is_batched = TRUE) {
  if (!$this
    ->prepareImport($context)) {
    return [];
  }

  // Add the selected UUIDs to the URL.
  // We do not handle offset or limit as we provide a maximum of 50 UUIDs.
  $url = $this->runtimeImportContext
    ->getChannelUrl();
  $prepared_url = EntityShareUtility::prepareUuidsFilteredUrl($url, $uuids);
  if ($is_batched) {
    $batch = [
      'title' => $this
        ->t('Import entities'),
      'operations' => [
        [
          '\\Drupal\\entity_share_client\\ImportBatchHelper::importUrlBatch',
          [
            $context,
            $prepared_url,
          ],
        ],
      ],
      'finished' => '\\Drupal\\entity_share_client\\ImportBatchHelper::importUrlBatchFinished',
    ];
    batch_set($batch);
  }
  else {
    return $this
      ->importFromUrl($prepared_url);
  }
}