Skip to content

[Messenger] Introduce HandlerDescriptorInterface #50998

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

ruudk
Copy link
Contributor

@ruudk ruudk commented Jul 17, 2023

Q A
Branch? 6.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets
License MIT
Doc PR

The HandlerDescriptor class is final and therefore cannot be extended. To make this a bit more flexible we introduce the HandlerDescriptorInterface that is used everywhere.

It also introduces a .messenger.handler_descriptor_class parameter that's used in the MessengerPass. With this parameter it's possible to use a custom implementation of the HandlersLocator.

This is an alternative approach to #50980. That PR also describes reasonings for this.

The `HandlerDescriptor` class is final and therefore cannot be extended. To make this a bit more
flexible we introduce the `HandlerDescriptorInterface` that is used everywhere.

It also introduces a `.messenger.handler_descriptor_class` parameter that's used in the
MessengerPass. With this parameter it's possible to use a custom implementation of the
`HandlersLocator`.

This is an alternative approach to symfony#50980.
@ruudk
Copy link
Contributor Author

ruudk commented Jul 17, 2023

Before I fix the failing tests, I'd like to know if this would be considered for merge or not.

@ruudk
Copy link
Contributor Author

ruudk commented Aug 3, 2023

@OskarStark what do you think about this?

@derrabus
Copy link
Member

derrabus commented Aug 3, 2023

It also introduces a .messenger.handler_descriptor_class parameter that's used in the MessengerPass.

We've removed this kind of parameter from our codebase and I don't think we want to start this again. A big issue with that class parameter is that it only works if the custom class uses the exact same constructor signature as the default implementation.

With this parameter it's possible to use a custom implementation of the HandlersLocator.

You could also just replace or decorate the service.

@ruudk
Copy link
Contributor Author

ruudk commented Aug 3, 2023

Ahh, didn't think of decorating! Will update the PR to remove the parameter.

@ruudk
Copy link
Contributor Author

ruudk commented Aug 3, 2023

@derrabus But how to decorate something like this:

foreach ($handlers as $handler) {
$definitions[$definitionId = '.messenger.handler_descriptor.'.ContainerBuilder::hash($bus.':'.$message.':'.$handler[0])] = (new Definition(HandlerDescriptor::class))->setArguments([new Reference($handler[0]), $handler[1]]);
$handlerDescriptors[] = new Reference($definitionId);
}

The only way I know, is to walk through the container definitions and find anything that starts with .messenger.handler_descriptor?

@ruudk
Copy link
Contributor Author

ruudk commented Aug 14, 2023

@nicolas-grekas What do you think of this?

@OskarStark
Copy link
Contributor

friendly ping @derrabus

@nicolas-grekas nicolas-grekas modified the milestones: 6.4, 7.1 Nov 15, 2023
@xabbuh xabbuh modified the milestones: 7.1, 7.2 May 15, 2024
@fabpot fabpot modified the milestones: 7.2, 7.3 Nov 20, 2024
@fabpot fabpot modified the milestones: 7.3, 7.4 May 26, 2025
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.

7 participants