class ImportedEntity in Acquia Content Hub 8.2
Any entity that has been previously imported shouldn't be enqueued.
@package Drupal\acquia_contenthub_publisher\EventSubscriber\EnqueueEligibility
Hierarchy
- class \Drupal\acquia_contenthub_publisher\EventSubscriber\EnqueueEligibility\ImportedEntity implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ImportedEntity
1 string reference to 'ImportedEntity'
- acquia_contenthub_publisher.services.yml in modules/
acquia_contenthub_publisher/ acquia_contenthub_publisher.services.yml - modules/acquia_contenthub_publisher/acquia_contenthub_publisher.services.yml
1 service uses ImportedEntity
- imported_entity.enqueue in modules/
acquia_contenthub_publisher/ acquia_contenthub_publisher.services.yml - Drupal\acquia_contenthub_publisher\EventSubscriber\EnqueueEligibility\ImportedEntity
File
- modules/
acquia_contenthub_publisher/ src/ EventSubscriber/ EnqueueEligibility/ ImportedEntity.php, line 15
Namespace
Drupal\acquia_contenthub_publisher\EventSubscriber\EnqueueEligibilityView source
class ImportedEntity implements EventSubscriberInterface {
/**
* The subscriber tracker.
*
* @var \Drupal\acquia_contenthub_subscriber\SubscriberTracker
*/
protected $subscriberTracker;
/**
* ImportedEntity constructor.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* Module Handler Interface.
*/
public function __construct(ModuleHandlerInterface $module_handler) {
if ($module_handler
->moduleExists('acquia_contenthub_subscriber')) {
$this->subscriberTracker = \Drupal::service('acquia_contenthub_subscriber.tracker');
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[ContentHubPublisherEvents::ENQUEUE_CANDIDATE_ENTITY][] = [
'onEnqueueCandidateEntity',
500,
];
return $events;
}
/**
* Prevents tracked imported entities to end up in the export queue.
*
* @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 (!empty($this->subscriberTracker) && $this->subscriberTracker
->isTracked($entity
->uuid())) {
$event
->setEligibility(FALSE);
$event
->stopPropagation();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ImportedEntity:: |
protected | property | The subscriber tracker. | |
ImportedEntity:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ImportedEntity:: |
public | function | Prevents tracked imported entities to end up in the export queue. | |
ImportedEntity:: |
public | function | ImportedEntity constructor. |