Before adding entities to the export queue, Content Hub checks the eligibility of an entity, and dispatches the ContentHubPublisherEvents::ENQUEUE_CANDIDATE_ENTITY
event. The subscribers of this event decide an entity's eligibility, and log the reason if it is ineligible to be enqueued to the export queue. You can export an ineligible entity as a dependency.
The following event subscribers that are enabled by default mark entities as ineligible based on the criteria:
Event subscriber | Description |
---|---|
EntityTypeOrBundleExclude | Marks selected entity types and bundles as ineligible for the export process. By using the ExcludeSettingsForm form, you can select entity types and bundles that you want to exclude from the export process. For more information about excluding entity types and bundles, see Excluding entities from export. |
ExcludeConfigEntities | Marks all config entities as ineligible. This prevents the system from enqueuing config entities. This occurs when the setting to exclude config entities from export is enabled in a module. For more information about excluding config entities, see Syndicating configuration with Content Hub. |
FileIsTemporary | Does not enqueue temporary files. |
FileSchemeIsSupported | Prevents enqueueing files with unsupported schemes. The supported schemes are:
|
ImportedEntity | Marks previously imported entities as ineligible. This is applicable for sites that are publisher and subscriber. |
IsAlreadyEnqueued | Prevents an entity that is already in the export queue. |
IsNotContentModerationState | Prevents the export of ContentModerationState entities. |
IsNotParagraph | Does not enqueue paragraphs. |
IsPathAliasForUnpublishedContent | Does not enqueue path aliases of unpublished content. |
MissingId | Does not enqueue entity with missing ID. |
MissingUuid | Does not enqueue entity with missing UUID. |
RevisionIsCurrent | Prevents the system from enqueueing unpublished revisions of the entity. |
You can create custom event subscribers that subscribe to the ContentHubPublisherEvents ::ENQUEUE_CANDIDATE_ENTITY
event. Acquia recommends that you set the eligibility of the entity inside such subscribers to false. For example, ContentHubEntityEligibilityEvent::setEligibility(FALSE)
. You can also provide your reason so that the system logs that information. For example, ContentHubEntityEligibilityEvent::setReason('Reason for marking entity ineligible');
.
Sample custom event subscriber:
<?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->setReason('Missing entity uuid.');
$event->stopPropagation();
}
}
}
If this content did not answer your questions, try searching or contacting our support team for further assistance.
Mon Oct 21 2024 12:41:34 GMT+0000 (Coordinated Universal Time)