public function WebformSubmissionHandler::onSerializeWebformElements in Acquia Content Hub 8.2
Serialize webform elements for webform submission entity.
Parameters
\Drupal\acquia_contenthub\Event\SerializeAdditionalMetadataEvent $event: Serialize event for additional metadata.
File
- src/
EventSubscriber/ Cdf/ WebformSubmissionHandler.php, line 40
Class
- WebformSubmissionHandler
- The Webform submission entity handler.
Namespace
Drupal\acquia_contenthub\EventSubscriber\CdfCode
public function onSerializeWebformElements(SerializeAdditionalMetadataEvent $event) {
$entity = $event
->getEntity();
// Bail early if this isn't a webform submission entity.
if (!$entity instanceof WebformSubmissionInterface) {
return;
}
$cdf = $event
->getCdf();
$metadata = $cdf
->getMetadata();
// Get webform elements data.
$webform_elements = $entity
->getData();
if ($webform_elements) {
$metadata['additional_data']['webform_elements'] = base64_encode(json_encode($webform_elements));
$cdf
->setMetadata($metadata);
$event
->setCdf($cdf);
}
$event
->stopPropagation();
}