-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Webhook] Allow configurators to be customized via Transport #61041
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 7.4
Are you sure you want to change the base?
Conversation
2e6cedb
to
0d0f227
Compare
0d0f227
to
7c07f66
Compare
This makes the configurators extensible in as much as it is simple to tag new configurators which can customize the http options.
7c07f66
to
f31864e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, here are some comments.
@@ -20,7 +20,8 @@ | |||
"symfony/http-foundation": "^6.4|^7.0|^8.0", | |||
"symfony/http-kernel": "^6.4|^7.0|^8.0", | |||
"symfony/messenger": "^6.4|^7.0|^8.0", | |||
"symfony/remote-event": "^6.4|^7.0|^8.0" | |||
"symfony/remote-event": "^6.4|^7.0|^8.0", | |||
"symfony/deprecation-contracts": "^2.5|^3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alpha order
} elseif (3 === count($params)) { | ||
trigger_deprecation('symfony/webhook', '7.3', 'Individual configurators for webhook transport is deprecated, use an iterable instead.'); | ||
|
||
$this->configurators = [ | ||
$params[0], | ||
$params[1], | ||
$params[2], | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} elseif (3 === count($params)) { | |
trigger_deprecation('symfony/webhook', '7.3', 'Individual configurators for webhook transport is deprecated, use an iterable instead.'); | |
$this->configurators = [ | |
$params[0], | |
$params[1], | |
$params[2], | |
]; | |
} elseif (3 < \count($params)) { | |
trigger_deprecation('symfony/webhook', '7.3', 'Individual configurators for webhook transport is deprecated, use an iterable instead.'); | |
$this->configurators = array_slice(\func_get_args(), 1); |
private readonly RequestConfiguratorInterface $headers, | ||
private readonly RequestConfiguratorInterface $body, | ||
private readonly RequestConfiguratorInterface $signer, | ||
...$params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should rather match the new expected type, with a BC layer:
...$params | |
RequestConfiguratorInterface|iterable $configurators |
$params[2], | ||
]; | ||
} else { | ||
throw new \InvalidArgumentException(sprintf('Expected a single Traversable argument or three configurators, got %d arguments.', count($params))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new \InvalidArgumentException(sprintf('Expected a single Traversable argument or three configurators, got %d arguments.', count($params))); | |
throw new \InvalidArgumentException(\sprintf('Expected a single iterable argument or three configurators, got %d arguments.', \count($params))); |
) { | ||
if (1 === count($params) && $params[0] instanceof \Traversable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (1 === count($params) && $params[0] instanceof \Traversable) { | |
if (1 === \count($params) && $params[0] instanceof \Traversable) { |
This makes the configurators extensible for the webhook transport service, in as much as it is simple to tag new configurators which can customize the http options.
This can be useful if you need to customize the webhook HTTP request, or any functionality implemented in a custom HttpClient. This customization can be done by inspecting the particular RemoteEvent.
https://symfony.com/bc
This will be a BC break for anyone who has already customized or used this Transport, unsure if that's acceptable.
There are not unit tests for this service, unsure if this is a design decision or some would be welcome as part of this change.