-
-
Notifications
You must be signed in to change notification settings - Fork 448
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
Added support for tagging entity listeners, without the need to map the listener #298
Conversation
Very nice 👍 |
+1 |
@stof Is this something you can accept into the bundle and what do you think about it ? |
OK, I'd really like to have that right now (if it works like described) |
+1 |
In keeping with conventions of other event listeners and subscribers the config property
But otherwise I would really love to see this feature added ASAP |
Would love to be able to use this feature! |
👍 Trying to implement this feature myself I came across this PR. Would love to see this getting merged. |
@hacfi I never really tested this in a real app. It should work but im not 100% sure. Have you or anyone else tried it ? |
@kimhemsoe Debugging this at the moment..looks like the entity listener isn’t added properly to the class metadata. |
eeafb14
to
da7a71d
Compare
@hacfi I have done a rebase to make it bit easier. |
|
||
$args = array( | ||
$serviceDef->getClass(), | ||
$attributes['entity'], |
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 be
$attributes['entity'],
$serviceDef->getClass(),
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.
Fixed
$listenerId = sprintf('doctrine.orm.%s_listeners.attach_entity_listeners', $entityManager['name']); | ||
$listenerDef = $container->setDefinition($listenerId, new Definition('%doctrine.orm.listeners.attach_entity_listeners.class%')); | ||
$listenerDef->addTag('doctrine.event_listener', array('event' => 'loadClassMetadata')); | ||
} |
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.
I don’t understand this part..using ORM 2.5.0 the listener is missing in the attachToListener
method.
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 quick update @kimhemsoe !
I think this should be
if (version_compare(Version::VERSION, "2.5.0-DEV") > 0) {
instead. doctrine.orm.listeners.attach_entity_listeners.class
isn’t available before 2.5 !?
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.
You are correct, i was a bit to fast in the rebase.
@kimhemsoe Perfect...works as expected now. As @chasen suggested the name |
The name "type" is from doctrine ORM, but "event" would be fine with me. |
Great! Thanks so much for this @kimhemsoe...I almost started writing a custom annotation for this 😜 |
You welcome @hacfi and thanks for the help. I will merge when travis and Scrutinizer returns green. |
Added support for tagging entity listeners, without the need to map the listener
@kimhemsoe Updating my current project to get the latest master..so useful I don’t want to wait :) |
Adds support for tagging entity listeners, defining entity and method.
Every listener service is created when the entitymanager is created for now. A solution could be marking the services lazy as suggested by @Ocramius and @stof in #223