You are here

public static function AuditTrackEntities::enqueueTrackedEntities in Acquia Content Hub 8.2

Adds entity to publisher export queue.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to enqueue to ContentHub.

string $audit_command: Commands trigger from pub or sub.

1 call to AuditTrackEntities::enqueueTrackedEntities()
AuditTrackEntities::batchProcess in src/AuditTrackEntities.php
Checks published entities and compares them with Content Hub.

File

src/AuditTrackEntities.php, line 104

Class

AuditTrackEntities
Audit Pub/Sub track entities.

Namespace

Drupal\acquia_contenthub

Code

public static function enqueueTrackedEntities(EntityInterface $entity, string $audit_command) {

  /** @var \Drupal\acquia_contenthub\PubSubModuleStatusChecker $check */
  $checker = \Drupal::service('pub.sub_status.checker');
  if ($checker
    ->isPublisher() && $audit_command === 'publisher_audit') {
    _acquia_contenthub_publisher_enqueue_entity($entity, 'update');
  }
  if ($checker
    ->isSubscriber() && $audit_command === 'subscriber_audit') {
    $item = new \stdClass();

    /** @var \Drupal\acquia_contenthub_subscriber\SubscriberTracker $tracker */
    $tracker = \Drupal::service('acquia_contenthub_subscriber.tracker');
    $queue = \Drupal::queue('acquia_contenthub_subscriber_import');
    $item->uuid = implode(', ', $entity
      ->uuid());
    $queue_id = $queue
      ->createItem($item);
    $tracker
      ->queue($entity);
    $tracker
      ->setQueueItemByUuid($item->uuid, $queue_id);
  }
}