You are here

public function PublishOnlyRendered::onEnqueueCandidateEntity in Acquia Lift Connector 8.4

Checks if the entity in hand is a renderable entity.

Only enqueue the entity if it is renderable.

Parameters

\Drupal\acquia_contenthub_publisher\Event\ContentHubEntityEligibilityEvent $event: The current enqueue eligibility event.

Throws

\Exception

File

modules/acquia_lift_publisher/src/EventSubscriber/Publish/PublishOnlyRendered.php, line 66

Class

PublishOnlyRendered
Responsible for filtering contents based on publishing configurations.

Namespace

Drupal\acquia_lift_publisher\EventSubscriber\Publish

Code

public function onEnqueueCandidateEntity(ContentHubEntityEligibilityEvent $event) : void {
  if (!$this
    ->personalizedContentPushIsActive()) {
    return;
  }
  $entity = $event
    ->getEntity();

  // If the entity view configuration on Acquia Lift Publisher settings page is
  // set for the entity in question, the entity is qualified to be processed.
  if (empty($this
    ->getEntityViewModesSettingValue($entity))) {
    $event
      ->setEligibility(FALSE);
    $event
      ->stopPropagation();
    return;
  }
  $entities = [];
  $cdfs = $this->commonActions
    ->getEntityCdf($entity, $entities, TRUE, FALSE);
  foreach ($cdfs as $cdf) {
    if ($cdf
      ->getType() !== 'rendered_entity') {
      continue;
    }
    $source_uuid = $this
      ->getCdfEntityAttributeValue($cdf, 'source_entity');
    if ($source_uuid === $entity
      ->uuid()) {
      $event
        ->setEligibility(TRUE);
      $event
        ->setCalculateDependencies(FALSE);
      return;
    }
  }
  $event
    ->setEligibility(FALSE);
  $event
    ->stopPropagation();
}