class TrackEntity in Acquia Content Hub 8.2
Tracks entities as their saved/updated.
Hierarchy
- class \Drupal\acquia_contenthub_subscriber\EventSubscriber\EntityImport\TrackEntity implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of TrackEntity
1 string reference to 'TrackEntity'
- 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 TrackEntity
- acquia_contenthub_subscriber.entity_import.track in modules/
acquia_contenthub_subscriber/ acquia_contenthub_subscriber.services.yml - Drupal\acquia_contenthub_subscriber\EventSubscriber\EntityImport\TrackEntity
File
- modules/
acquia_contenthub_subscriber/ src/ EventSubscriber/ EntityImport/ TrackEntity.php, line 13
Namespace
Drupal\acquia_contenthub_subscriber\EventSubscriber\EntityImportView source
class TrackEntity 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() {
$events[AcquiaContentHubEvents::ENTITY_IMPORT_NEW][] = [
'trackEntity',
100,
];
$events[AcquiaContentHubEvents::ENTITY_IMPORT_UPDATE][] = [
'trackEntity',
100,
];
return $events;
}
/**
* Tracks entities being saved for the first time.
*
* @param \Drupal\acquia_contenthub\Event\EntityImportEvent $event
* The entity import event.
*
* @throws \Exception
*/
public function trackEntity(EntityImportEvent $event) {
$entity = $event
->getEntity();
$cdf_object = $event
->getEntityData();
$hash = $cdf_object
->getAttribute('hash')
->getValue()['und'];
$this->tracker
->track($entity, $hash, $cdf_object
->getUuid());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TrackEntity:: |
protected | property | The subscriber tracker. | |
TrackEntity:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
TrackEntity:: |
public | function | Tracks entities being saved for the first time. | |
TrackEntity:: |
public | function | TrackEntity constructor. |