Skip to content

[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

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from

Conversation

rodnaph
Copy link
Contributor

@rodnaph rodnaph commented Jul 5, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues None
License MIT

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.

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.

@carsonbot carsonbot added this to the 7.4 milestone Jul 5, 2025
@rodnaph rodnaph force-pushed the webhook-transport-configuration branch from 2e6cedb to 0d0f227 Compare July 5, 2025 18:12
@rodnaph rodnaph force-pushed the webhook-transport-configuration branch from 0d0f227 to 7c07f66 Compare July 6, 2025 18:49
This makes the configurators extensible in as much as it is simple to
tag new configurators which can customize the http options.
@rodnaph rodnaph force-pushed the webhook-transport-configuration branch from 7c07f66 to f31864e Compare July 6, 2025 19:15
Copy link
Member

@nicolas-grekas nicolas-grekas left a 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alpha order

Comment on lines +32 to +39
} 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],
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} 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
Copy link
Member

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:

Suggested change
...$params
RequestConfiguratorInterface|iterable $configurators

$params[2],
];
} else {
throw new \InvalidArgumentException(sprintf('Expected a single Traversable argument or three configurators, got %d arguments.', count($params)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (1 === count($params) && $params[0] instanceof \Traversable) {
if (1 === \count($params) && $params[0] instanceof \Traversable) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy