feat(subscriber): auto-register EmbeddedEventResolverInterface event classes as listeners#66
Open
nowshad7 wants to merge 2 commits intoxiidea:masterfrom
Open
Conversation
…classes as listeners
ronisaha
reviewed
Mar 21, 2026
Member
ronisaha
left a comment
There was a problem hiding this comment.
If we change those the test case changes would no longer needed.
| $container->setParameter('xiidea.easy_audit.' . $key, $value); | ||
| } | ||
|
|
||
| $container->registerForAutoconfiguration(EmbeddedEventResolverInterface::class) |
Member
There was a problem hiding this comment.
Instead of defining in code, it is easy to define in configuration like:
Xiidea\EasyAuditBundle\Resolver\EmbeddedEventResolverInterface:
tags: ['easy_audit.embedded_event']|
|
||
| $this->appendDoctrineEventsToList($container, $eventsList); | ||
| $this->appendSubscribedEventsToList($container, $eventsList); | ||
| $this->appendEmbeddedEventClasses($container, $eventsList); |
Member
There was a problem hiding this comment.
Instead of doing it manually, as this event is typed, try to solve it using typed event
ed48f63 to
4d2b9fa
Compare
4d2b9fa to
d5d8d13
Compare
Author
|
Hello @ronisaha dada, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & Why
EmbeddedEventResolverInterfacealready lets an event describe its own audit payload, but using it still required extra subscriber wiring just to get the event to the bundle listener. That meant the embedded-resolver flow carried boilerplate even though the runtime resolver path already knew how to handle these events.This PR removes that manual registration step and lets embedded audit events be routed through Symfony's event system directly.
Before
After
How
This is implemented with a small Symfony-aligned change set:
Resources/config/services.ymlRegisters
xiidea.easy_audit.event_listeneras akernel.event_listenerforEmbeddedEventResolverInterface::class.Listener/LogEventsListener.phpWhen an embedded event is dispatched via the interface shortcut, the listener converts the event name from
EmbeddedEventResolverInterface::classto the concrete event class so audit entries keep a meaningfultype/typeId.DependencyInjection/Compiler/SubscriberPass.phpPreserves existing
kernel.event_listenertags when adding listener registrations, so the static interface-based listener registration is not overwritten.Why This Approach
Compatibility
There is no breaking change for existing users.
events:configuration still works.EmbeddedEventResolverInterface::class.Tests & Docs
Resources/doc/embed-resolver.mdto document the new interface-based dispatch shortcut and keep the subscriber-based alternative documented.EmbeddedEventResolverInterface::classand asserting the concrete class is used in the audit log.Passed:
7 tests, 39 assertions.