class LoadFromTrackingData in Acquia Content Hub 8.2
Class LoadFromTrackingData.
Matches tracking data to local entities.
@package Drupal\acquia_contenthub_subscriber\EventSubscriber\LoadFromTrackingData
Hierarchy
- class \Drupal\acquia_contenthub_subscriber\EventSubscriber\LoadLocalEntity\LoadFromTrackingData implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of LoadFromTrackingData
1 string reference to 'LoadFromTrackingData'
- acquia_contenthub_subscriber.services.yml in modules/
acquia_contenthub_subscriber/ acquia_contenthub_subscriber.services.yml - modules/acquia_contenthub_subscriber/acquia_contenthub_subscriber.services.yml
1 service uses LoadFromTrackingData
File
- modules/
acquia_contenthub_subscriber/ src/ EventSubscriber/ LoadLocalEntity/ LoadFromTrackingData.php, line 17
Namespace
Drupal\acquia_contenthub_subscriber\EventSubscriber\LoadLocalEntityView source
class LoadFromTrackingData implements EventSubscriberInterface {
/**
* The subscriber tracker.
*
* @var \Drupal\acquia_contenthub_subscriber\SubscriberTracker
*/
protected $tracker;
/**
* TrackEntity constructor.
*
* @param \Drupal\acquia_contenthub_subscriber\SubscriberTracker $tracker
* The subscriber tracker.
*/
public function __construct(SubscriberTracker $tracker) {
$this->tracker = $tracker;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
AcquiaContentHubEvents::LOAD_LOCAL_ENTITY => [
'onLoadLocalEntity',
110,
],
];
}
/**
* Load previously imported entities from the tracking table data.
*
* @param \Drupal\acquia_contenthub\Event\LoadLocalEntityEvent $event
* Data tamper event.
*
* @throws \Exception
*/
public function onLoadLocalEntity(LoadLocalEntityEvent $event) {
$cdf = $event
->getCdf();
if ($this->tracker
->isTracked($cdf
->getUuid())) {
$entity = $this->tracker
->getEntityByRemoteIdAndHash($cdf
->getUuid());
// No entity found, let the rest of the stack do its job.
if (!$entity) {
return;
}
$event
->setEntity($entity);
$event
->stopPropagation();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LoadFromTrackingData:: |
protected | property | The subscriber tracker. | |
LoadFromTrackingData:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
LoadFromTrackingData:: |
public | function | Load previously imported entities from the tracking table data. | |
LoadFromTrackingData:: |
public | function | TrackEntity constructor. |