in src/LegacyEventMapper.php [89:148]
public function fromJsonData(array $jsonData, string $requestUriPath): CloudEvent
{
[$context, $data] = $this->getLegacyEventContextAndData($jsonData, $requestUriPath);
$eventType = $context->getEventType();
$resourceName = $context->getResourceName();
$ceId = $context->getEventId();
// Mapped from eventType.
$ceType = $this->ceType($eventType);
// From context/resource/service, or mapped from eventType.
$ceService = $context->getService() ?: $this->ceService($eventType);
// Split the background event resource into a CloudEvent resource and subject.
[$ceResource, $ceSubject] = $this->ceResourceAndSubject(
$ceService,
$resourceName,
$context->getDomain()
);
$ceTime = $context->getTimestamp();
if ($ceService === self::PUBSUB_CE_SERVICE) {
// Handle Pub/Sub events.
if (!is_array($data)) {
$data = ['data' => $data];
}
$data['messageId'] = $context->getEventId();
$data['publishTime'] = $context->getTimestamp();
$data = ['message' => $data];
} elseif ($ceService === self::FIREBASE_AUTH_CE_SERVICE) {
// Handle Firebase Auth events.
if (array_key_exists('metadata', $data)) {
foreach (self::$firebaseAuthMetadataFieldMap as $old => $new) {
if (array_key_exists($old, $data['metadata'])) {
$data['metadata'][$new] = $data['metadata'][$old];
unset($data['metadata'][$old]);
}
}
}
if (array_key_exists('uid', $data)) {
$ceSubject = sprintf('users/%s', $data['uid']);
}
}
return CloudEvent::fromArray([
'id' => $ceId,
'source' => sprintf('//%s/%s', $ceService, $ceResource),
'specversion' => '1.0',
'type' => $ceType,
'datacontenttype' => 'application/json',
'dataschema' => null,
'subject' => $ceSubject,
'time' => $ceTime,
'data' => $data,
]);
}