MissingUuid.php in Acquia Content Hub 8.2
File
modules/acquia_contenthub_publisher/src/EventSubscriber/EnqueueEligibility/MissingUuid.phpView source
<?php
namespace Drupal\acquia_contenthub_publisher\EventSubscriber\EnqueueEligibility;
use Drupal\acquia_contenthub_publisher\ContentHubPublisherEvents;
use Drupal\acquia_contenthub_publisher\Event\ContentHubEntityEligibilityEvent;
use Drupal\Component\Uuid\Uuid;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Any entity that is missing its UUID shouldn't be enqueued.
*
* @package Drupal\acquia_contenthub_publisher\EventSubscriber\EnqueueEligibility
*/
class MissingUuid implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[ContentHubPublisherEvents::ENQUEUE_CANDIDATE_ENTITY][] = [
'onEnqueueCandidateEntity',
1000,
];
return $events;
}
/**
* Skips entities missing its UUID.
*
* @param \Drupal\acquia_contenthub_publisher\Event\ContentHubEntityEligibilityEvent $event
* The event to determine entity eligibility.
*
* @throws \Exception
*/
public function onEnqueueCandidateEntity(ContentHubEntityEligibilityEvent $event) {
$entity = $event
->getEntity();
if (!Uuid::isValid($entity
->uuid())) {
$event
->setEligibility(FALSE);
$event
->stopPropagation();
}
}
}
Classes
Name | Description |
---|---|
MissingUuid | Any entity that is missing its UUID shouldn't be enqueued. |