diff --git a/functions/helloworld_pubsub/index.php b/functions/helloworld_pubsub/index.php index 3aac9ff60..e232b6f83 100644 --- a/functions/helloworld_pubsub/index.php +++ b/functions/helloworld_pubsub/index.php @@ -26,10 +26,7 @@ // This enables omitting the `FUNCTIONS_SIGNATURE_TYPE=cloudevent` environment // variable when deploying. The `FUNCTION_TARGET` environment variable should // match the first parameter. -FunctionsFramework::cloudEvent('helloworldPubsub', 'helloworldPubsub'); - -function helloworldPubsub(CloudEventInterface $event): void -{ +FunctionsFramework::cloudEvent('helloworldPubsub', function (CloudEventInterface $event) { $log = fopen(getenv('LOGGER_OUTPUT') ?: 'php://stderr', 'wb'); $cloudEventData = $event->getData(); @@ -37,6 +34,6 @@ function helloworldPubsub(CloudEventInterface $event): void $name = $pubSubData ? htmlspecialchars($pubSubData) : 'World'; fwrite($log, "Hello, $name!" . PHP_EOL); -} +}); // [END functions_helloworld_pubsub] // [END functions_cloudevent_pubsub] diff --git a/functions/helloworld_storage/index.php b/functions/helloworld_storage/index.php index f3e886c02..55b15398d 100644 --- a/functions/helloworld_storage/index.php +++ b/functions/helloworld_storage/index.php @@ -26,10 +26,7 @@ // This enables omitting the `FUNCTIONS_SIGNATURE_TYPE=cloudevent` environment // variable when deploying. The `FUNCTION_TARGET` environment variable should // match the first parameter. -FunctionsFramework::cloudEvent('helloGCS', 'helloGCS'); - -function helloGCS(CloudEventInterface $cloudevent) -{ +FunctionsFramework::cloudEvent('helloGCS', function (CloudEventInterface $cloudevent) { // This function supports all Cloud Storage event types. $log = fopen(getenv('LOGGER_OUTPUT') ?: 'php://stderr', 'wb'); $data = $cloudevent->getData(); @@ -40,7 +37,7 @@ function helloGCS(CloudEventInterface $cloudevent) fwrite($log, 'Metageneration: ' . $data['metageneration'] . PHP_EOL); fwrite($log, 'Created: ' . $data['timeCreated'] . PHP_EOL); fwrite($log, 'Updated: ' . $data['updated'] . PHP_EOL); -} +}); // [END functions_cloudevent_storage] // [END functions_helloworld_storage]