Skip to content

Commit 481d6c6

Browse files
feature #1512 Changed comment to be more explicit on generated method modification + fix generated code
1 parent c4f8d2c commit 481d6c6

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/Resources/skeleton/webhook/RequestParser.tpl.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ protected function getRequestMatcher(): RequestMatcherInterface
2626
*/
2727
protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?RemoteEvent
2828
{
29-
// Implement your own logic to validate and parse the request, and return a RemoteEvent object.
29+
// TODO: Adapt or replace the content of this method to fit your need.
3030

3131
// Validate the request against $secret.
3232
$authToken = $request->headers->get('X-Authentication-Token');
33-
if (is_null($authToken) || $authToken !== $secret) {
33+
if ($authToken !== $secret) {
3434
throw new RejectWebhookException(Response::HTTP_UNAUTHORIZED, 'Invalid authentication token.');
3535
}
3636

tests/fixtures/make-webhook/RemoteServiceRequestParser.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ protected function getRequestMatcher(): RequestMatcherInterface
2525
*/
2626
protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?RemoteEvent
2727
{
28-
// Implement your own logic to validate and parse the request, and return a RemoteEvent object.
28+
// TODO: Adapt or replace the content of this method to fit your need.
2929

3030
// Validate the request against $secret.
3131
$authToken = $request->headers->get('X-Authentication-Token');
32-
33-
if (null === $authToken || $authToken !== $secret) {
32+
if ($authToken !== $secret) {
3433
throw new RejectWebhookException(Response::HTTP_UNAUTHORIZED, 'Invalid authentication token.');
3534
}
3635

@@ -41,7 +40,7 @@ protected function doParse(Request $request, #[\SensitiveParameter] string $secr
4140
}
4241

4342
// Parse the request payload and return a RemoteEvent object.
44-
$payload = $request->getPayload()->getIterator()->getArrayCopy();
43+
$payload = $request->getPayload()->all();
4544

4645
return new RemoteEvent(
4746
$payload['name'],

0 commit comments

Comments
 (0)