public function IsAlreadyEnqueued::onEnqueueCandidateEntity in Acquia Content Hub 8.2
Prevents entities already in the export queue to be enqueued again.
Parameters
\Drupal\acquia_contenthub_publisher\Event\ContentHubEntityEligibilityEvent $event: The event to determine entity eligibility.
Throws
\Exception
File
- modules/
acquia_contenthub_publisher/ src/ EventSubscriber/ EnqueueEligibility/ IsAlreadyEnqueued.php, line 63
Class
- IsAlreadyEnqueued
- Any entity that is already in the export queue shouldn't be enqueued.
Namespace
Drupal\acquia_contenthub_publisher\EventSubscriber\EnqueueEligibilityCode
public function onEnqueueCandidateEntity(ContentHubEntityEligibilityEvent $event) {
$uuid = $event
->getEntity()
->uuid();
if (!Uuid::isValid($uuid)) {
return;
}
// Get the queue_id from the tracker first.
$item_id = $this->tracker
->getQueueId($uuid);
if (!empty($item_id)) {
// This entity is already in the export queue. Log about it?
$event
->setEligibility(FALSE);
$event
->stopPropagation();
}
}