-
Notifications
You must be signed in to change notification settings - Fork 518
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
[WIP] Refactor event system #106
Conversation
Refactor event-listeners
Remove event subscriber
@ftassi Any feedback? |
@Baachi nice one 👍 |
I recently came across the error where the upload handler was not triggered if only the image had been changed. Now im back with the same situation in a new project... having this issue solved in the bundle would be nice. @dustin10 Any comments/proposals on this PR ? I would be willing to help out if something's missing. |
Hi @Baachi thanks for the PR and sorry for late responding. Here are my thoughts about it. We have 4 events that should trigger 4 different actions:
The user should be able to configure those 4 behaviours independently and I also would like to let the user free to define them globally or for at mapping level (specific mapping config should override globals). Sadly we're not able to tag or untag listeners at runtime(are we?), I think we need to always call the listeners, pass the configuration data to the PropertyMapping class and use it to decide what to do for each uploadable field. This is an example of what I'm talking about (as the bundle already do something like this): https://github.com/dustin10/VichUploaderBundle/blob/master/Storage/AbstractStorage.php#L94 Does this make sense for you? |
@@ -28,6 +28,9 @@ public function getConfigTreeBuilder() | |||
->scalarNode('storage')->defaultValue('vich_uploader.storage.file_system')->end() | |||
->scalarNode('twig')->defaultTrue()->end() | |||
->scalarNode('gaufrette')->defaultFalse()->end() | |||
->scalarNode('upload_on_persist')->defaultTrue()->end() | |||
->scalarNode('unlink_on_remove')->defaultTrue()->end() |
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.
should be delete_on_remove for consistence with mapping node
also delete_on_update is missing here
@ftassi Attach the listeners at runtime is not easy, because we can not use the DIC. But your suggestions make sense and i will follow your suggestions. I hope i will find some time at this weekend to finish this PR. |
👌 |
a possible alternative solution could be listen preFlush event instead of preUpdate, something like this:
I have taken this piece of code from a project in which I used an interface, but it's easy implement it via annotations |
any news? |
@sirian Currently i'm very busy, but if you want send PR's to my branch and i will merge it, so it will be vissible here. |
What's the status of this PR? |
I'm currently haven't any project which use the |
@K-Phoen can i close this PR? |
Yep :) Do you think there are still things in your PR that we should backport into the actual codebase? |
I don't think so, you do a great job with this PR #183 . |
Hey,
I refactored the event system a little bit. Now you can configure which listeners should be triggerd and which not.
So if you have some issues with upload a file/image, like #8. You can disable the event listener and upload the file by hand.
Feedback, please!
Todo