public function ExistingEntity::onDataTamper in Acquia Content Hub 8.2
Tamper with CDF data before its imported.
Parameters
\Drupal\acquia_contenthub\Event\EntityDataTamperEvent $event: The data tamper event.
Throws
\Exception
File
- modules/
acquia_contenthub_subscriber/ src/ EventSubscriber/ EntityDataTamper/ ExistingEntity.php, line 53
Class
- ExistingEntity
- Place existing entities into the dependency stack.
Namespace
Drupal\acquia_contenthub_subscriber\EventSubscriber\EntityDataTamperCode
public function onDataTamper(EntityDataTamperEvent $event) {
$cdf = $event
->getCdf();
foreach ($cdf
->getEntities() as $uuid => $object) {
// @todo we want to compare by hashes eventually.
$hash = $object
->getAttribute('hash')
->getValue()['und'];
$entity = $this->tracker
->getEntityByRemoteIdAndHash($uuid, $hash);
if ($entity) {
$wrapper = new DependentEntityWrapper($entity);
$wrapper
->setRemoteUuid($uuid);
$event
->getStack()
->addDependency($wrapper);
$this->tracker
->setStatusByUuid($uuid, SubscriberTracker::IMPORTED);
}
}
}