diff --git a/src/Maker/MakeWebhook.php b/src/Maker/MakeWebhook.php index e537f560e..300c15731 100644 --- a/src/Maker/MakeWebhook.php +++ b/src/Maker/MakeWebhook.php @@ -132,8 +132,8 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen Str::asClassName($this->name.'RequestParser'), 'Webhook\\' ); - $remoteEventHandlerDetails = $this->generator->createClassNameDetails( - Str::asClassName($this->name.'WebhookHandler'), + $remoteEventConsumerDetails = $this->generator->createClassNameDetails( + Str::asClassName($this->name.'WebhookConsumer'), 'RemoteEvent\\' ); @@ -142,8 +142,8 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen $this->generateRequestParser($io, $requestParserDetails); $this->generator->generateClass( - $remoteEventHandlerDetails->getFullName(), - 'webhook/WebhookHandler.tpl.php', + $remoteEventConsumerDetails->getFullName(), + 'webhook/WebhookConsumer.tpl.php', [ 'webhook_name' => $this->name, ] diff --git a/src/Resources/skeleton/webhook/RequestParser.tpl.php b/src/Resources/skeleton/webhook/RequestParser.tpl.php index 98610b5d6..9a60fc972 100644 --- a/src/Resources/skeleton/webhook/RequestParser.tpl.php +++ b/src/Resources/skeleton/webhook/RequestParser.tpl.php @@ -41,7 +41,7 @@ protected function doParse(Request $request, #[\SensitiveParameter] string $secr } // Parse the request payload and return a RemoteEvent object. - $payload = $request->getPayload()->getIterator()->getArrayCopy(); + $payload = $request->getPayload()->all(); return new RemoteEvent( $payload['name'], diff --git a/src/Resources/skeleton/webhook/WebhookHandler.tpl.php b/src/Resources/skeleton/webhook/WebhookConsumer.tpl.php similarity index 100% rename from src/Resources/skeleton/webhook/WebhookHandler.tpl.php rename to src/Resources/skeleton/webhook/WebhookConsumer.tpl.php diff --git a/tests/Maker/MakeWebhookTest.php b/tests/Maker/MakeWebhookTest.php index 4fcb5d4bb..830386ab3 100644 --- a/tests/Maker/MakeWebhookTest.php +++ b/tests/Maker/MakeWebhookTest.php @@ -38,10 +38,10 @@ public function getTestDetails(): \Generator 'use Symfony\Component\Webhook\Client\AbstractRequestParser;', file_get_contents($runner->getPath('src/Webhook/RemoteServiceRequestParser.php')) ); - $this->assertFileExists($runner->getPath('src/RemoteEvent/RemoteServiceWebhookHandler.php')); + $this->assertFileExists($runner->getPath('src/RemoteEvent/RemoteServiceWebhookConsumer.php')); $this->assertStringContainsString( '#[AsRemoteEventConsumer(\'remote_service\')]', - file_get_contents($runner->getPath('src/RemoteEvent/RemoteServiceWebhookHandler.php')), + file_get_contents($runner->getPath('src/RemoteEvent/RemoteServiceWebhookConsumer.php')), ); $securityConfig = $runner->readYaml('config/packages/webhook.yaml'); $this->assertEquals( @@ -59,7 +59,7 @@ public function getTestDetails(): \Generator ->run(function (MakerTestRunner $runner) { $runner->copy('make-webhook/webhook.yaml', 'config/packages/webhook.yaml'); $runner->copy('make-webhook/RemoteServiceRequestParser.php', 'src/Webhook/RemoteServiceRequestParser.php'); - $runner->copy('make-webhook/RemoteServiceWebhookHandler.php', 'src/RemoteEvent/RemoteServiceWebhookHandler.php'); + $runner->copy('make-webhook/RemoteServiceWebhookConsumer.php', 'src/RemoteEvent/RemoteServiceWebhookConsumer.php'); $output = $runner->runMaker([ // webhook name 'another_remote_service', @@ -68,7 +68,7 @@ public function getTestDetails(): \Generator ]); $this->assertStringContainsString('created:', $output); $this->assertFileExists($runner->getPath('src/Webhook/AnotherRemoteServiceRequestParser.php')); - $this->assertFileExists($runner->getPath('src/RemoteEvent/AnotherRemoteServiceWebhookHandler.php')); + $this->assertFileExists($runner->getPath('src/RemoteEvent/AnotherRemoteServiceWebhookConsumer.php')); $securityConfig = $runner->readYaml('config/packages/webhook.yaml'); // original config should not be modified $this->assertArrayHasKey('remote_service', $securityConfig['framework']['webhook']['routing']); @@ -103,7 +103,7 @@ public function getTestDetails(): \Generator ]); $this->assertStringContainsString('created:', $output); $this->assertFileExists($runner->getPath('src/Webhook/RemoteServiceRequestParser.php')); - $this->assertFileExists($runner->getPath('src/RemoteEvent/RemoteServiceWebhookHandler.php')); + $this->assertFileExists($runner->getPath('src/RemoteEvent/RemoteServiceWebhookConsumer.php')); $requestParserSource = file_get_contents($runner->getPath('src/Webhook/RemoteServiceRequestParser.php')); $this->assertStringContainsString( 'use Symfony\Component\HttpFoundation\RequestMatcher\IsJsonRequestMatcher;', @@ -127,7 +127,7 @@ public function getTestDetails(): \Generator ]); $this->assertStringContainsString('created:', $output); $this->assertFileExists($runner->getPath('src/Webhook/RemoteServiceRequestParser.php')); - $this->assertFileExists($runner->getPath('src/RemoteEvent/RemoteServiceWebhookHandler.php')); + $this->assertFileExists($runner->getPath('src/RemoteEvent/RemoteServiceWebhookConsumer.php')); $requestParserSource = file_get_contents($runner->getPath('src/Webhook/RemoteServiceRequestParser.php')); $this->assertStringContainsString( 'use Symfony\Component\HttpFoundation\RequestMatcher\IsJsonRequestMatcher;', @@ -165,7 +165,7 @@ public function getTestDetails(): \Generator ]); $this->assertStringContainsString('created:', $output); $this->assertFileExists($runner->getPath('src/Webhook/RemoteServiceRequestParser.php')); - $this->assertFileExists($runner->getPath('src/RemoteEvent/RemoteServiceWebhookHandler.php')); + $this->assertFileExists($runner->getPath('src/RemoteEvent/RemoteServiceWebhookConsumer.php')); $requestParserSource = file_get_contents($runner->getPath('src/Webhook/RemoteServiceRequestParser.php')); $this->assertStringContainsString( 'use Symfony\Component\HttpFoundation\RequestMatcher\IsJsonRequestMatcher;', diff --git a/tests/fixtures/make-webhook/RemoteServiceWebhookHandler.php b/tests/fixtures/make-webhook/RemoteServiceWebhookConsumer.php similarity index 85% rename from tests/fixtures/make-webhook/RemoteServiceWebhookHandler.php rename to tests/fixtures/make-webhook/RemoteServiceWebhookConsumer.php index 0a0e35d21..fe9dd0c4c 100644 --- a/tests/fixtures/make-webhook/RemoteServiceWebhookHandler.php +++ b/tests/fixtures/make-webhook/RemoteServiceWebhookConsumer.php @@ -7,7 +7,7 @@ use Symfony\Component\RemoteEvent\RemoteEvent; #[AsRemoteEventConsumer('remote_service')] -final class RemoteServiceWebhookHandler implements ConsumerInterface +final class RemoteServiceWebhookConsumer implements ConsumerInterface { public function __construct() {