You are here

protected function AcquiaContentHubEnqueueEntitiesCommands::enqueueWithoutTrackingTable in Acquia Content Hub 8.2

Requeue entities without using the Tracking Table.

Parameters

string|bool|null $entity_type: The entity type.

string|bool|null $bundle: The entity bundle.

array $data: The data array.

\Drupal\Core\Entity\EntityStorageInterface|null $storage: A storage instance.

Return value

mixed The return to print in the screen.

Throws

\Exception

1 call to AcquiaContentHubEnqueueEntitiesCommands::enqueueWithoutTrackingTable()
AcquiaContentHubEnqueueEntitiesCommands::enqueueEntities in modules/acquia_contenthub_publisher/src/Commands/AcquiaContentHubEnqueueEntitiesCommands.php
Re-queues entities to Acquia Content Hub.

File

modules/acquia_contenthub_publisher/src/Commands/AcquiaContentHubEnqueueEntitiesCommands.php, line 260

Class

AcquiaContentHubEnqueueEntitiesCommands
Drush commands for Acquia Content Hub enqueue entities.

Namespace

Drupal\acquia_contenthub_publisher\Commands

Code

protected function enqueueWithoutTrackingTable($entity_type, $bundle, array $data, $storage) {
  if (empty($entity_type)) {
    return $this->output
      ->writeln('<error>You cannot use the command without any options. Please provide at least one option.</error>');
  }

  // We are going to re-queue ALL entities that match a particular entity
  // type (and bundle) disregarding whether they have been previously
  // published or not.
  // Re-enqueue all entities.
  $entities = $storage
    ->loadByProperties($data);
  if (empty($entities)) {
    return $this->output
      ->writeln(sprintf('<error>No entities found for bundle = "%s".</error>', $bundle));
  }
  $count = 0;
  foreach ($entities as $entity) {
    _acquia_contenthub_publisher_enqueue_entity($entity, 'update');
    $count++;
  }
  $msg = !empty($bundle) ? "and bundle = \"{$bundle}\"." : '';
  return $this->output
    ->writeln(sprintf('<info>Processed %s entities of type = "%s" %s for export.</info>', $count, $entity_type, $msg));
}