-
Notifications
You must be signed in to change notification settings - Fork 29
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
Consider adding automatically prefixed pre and post action hooks on CRUD methods within query class #138
Comments
This is something we've discussed wanting for EDD, specifically when we introduced hooks for adding, updating, and deleting order items (here's what we did for adding). On the one hand, those are hooks that can get triggered frequently and often--technically every time an object is changed somehow. On the other hand, there are a lot of different ways, times, and places to interact with [order] data, and trying to make sure that one thing happens consistently (or potentially happens) with every change requires a hook at this level. So we've done hooks like $this->apply_prefix( $this->item_name ) . '_added' which would ideally be tucked right before the |
I actually use BerlinDB in a lot of my own personal projects and built out an extension of the query class that adds CRUD actions/filters to almost all the methods. Here is what it looks like:
Maybe EDD could do it a similar way? Keeps everything a lot more DRY imho. |
Here is an example of a function within my code base for a third-party plugin I am building for EDD 3.0:
For almost all methods I had to add
pre
andpost
do_actions
passing in the ID and return value, which bloats the code base a bit too much for my liking.Much like the transition method hook, it would be useful to have these actions automatically generated for all the main CRUD methods. Ideally it should be possible to override that prefix too if you are building an add-on for another plugin (like EDD 3.0). Maybe this override could be defined in the query class schema or somewhere similar.
The text was updated successfully, but these errors were encountered: