Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Mar 23, 2024

Q A
Branch? 7.1
Bug fix? no
New feature? no
Deprecations? no
Issues -
License MIT

All the Workflow\Attribute\As*Listener classes extend AsEventListener. Since the attribute handler are now applied to child classes (#54365), it's no longer necessary to declare an attribute handler for each attribute.

Discussed in #54365 (comment)

@GromNaN GromNaN added this to the 7.1 milestone Mar 23, 2024
@GromNaN GromNaN requested a review from lyrixx March 23, 2024 10:55
@carsonbot carsonbot changed the title Remove custom handler for Workflow listener attributes [FrameworkBundle] Remove custom handler for Workflow listener attributes Mar 23, 2024
$tagAttributes = get_object_vars($attribute);
if ($reflector instanceof \ReflectionMethod) {
if (isset($tagAttributes['method'])) {
throw new LogicException(sprintf('"%s" attribute cannot declare a method on "%s::%s()".', $attribute::class, $reflector->class, $reflector->name));
Copy link
Member Author

@GromNaN GromNaN Mar 23, 2024

Choose a reason for hiding this comment

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

This closure was identical to AsEventListener, except this exception message.

$container->registerAttributeForAutoconfiguration(AsEventListener::class, static function (ChildDefinition $definition, AsEventListener $attribute, \ReflectionClass|\ReflectionMethod $reflector) {
$tagAttributes = get_object_vars($attribute);
if ($reflector instanceof \ReflectionMethod) {
if (isset($tagAttributes['method'])) {
throw new LogicException(sprintf('AsEventListener attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name));
}
$tagAttributes['method'] = $reflector->getName();
}
$definition->addTag('kernel.event_listener', $tagAttributes);
});

@nicolas-grekas
Copy link
Member

Thank you @GromNaN.

@nicolas-grekas nicolas-grekas merged commit cd2fc45 into symfony:7.1 Mar 23, 2024
@GromNaN GromNaN deleted the workflow-attributes branch March 23, 2024 11:07
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.

2 participants