You are here

public function RevisionIsCurrent::onEnqueueCandidateEntity in Acquia Content Hub 8.2

Allows to enqueue only the current revision of an entity.

Parameters

\Drupal\acquia_contenthub_publisher\Event\ContentHubEntityEligibilityEvent $event: The event to determine entity eligibility.

Throws

\Exception

File

modules/acquia_contenthub_publisher/src/EventSubscriber/EnqueueEligibility/RevisionIsCurrent.php, line 49

Class

RevisionIsCurrent
Subscribes to entity eligibility to prevent enqueuing unpublished revisions.

Namespace

Drupal\acquia_contenthub_publisher\EventSubscriber\EnqueueEligibility

Code

public function onEnqueueCandidateEntity(ContentHubEntityEligibilityEvent $event) {
  $entity = $event
    ->getEntity();

  // If entity transitioned from published to unpublished state
  // then do not prevent export.
  if ($this->entityModeratedRevision
    ->isTransitionedToUnpublished($entity)) {
    return;
  }
  if (!$this->entityModeratedRevision
    ->isPublishedRevision($entity)) {

    // This revision has no published translation then do not syndicate.
    $event
      ->setEligibility(FALSE);
    $event
      ->stopPropagation();
  }
}