This repository has been archived by the owner on Dec 3, 2018. It is now read-only.
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.
Each forum thread is related to one entity on my site. So I am creating threads, merging and deleting them as I create update and delete my own entities. In order for the forums to "talk" back to the main application, I had to add an events system.
src/events/EventService
- easy way of sending events.src/events/PodiumEvent
- event names.src/events/PodiumThreadEvent
- event object for events about threads.I have triggered thread events inside
Thread
andPost
. To keep it simple, I trigger a thread update event whenever anything happens to the posts of that thread.Using it is easy:
main.php
PodiumListener.php
I just needed to have my entity's last modified time linked with the thread, but after doing it I can see loads of other possibilities with other events. One that sprang to mind was catching each
Post
create/update, parsing the URLs out of it and filing them somewhere else.I can see it being useful to run actions when threads or posts are created, etc.
Like I said, I've kept it simple to see what the reaction is like.
The only thing worth mentioning is that I wasn't sure if you wanted to include the event triggering inside the thread create/update/delete transaction. I decided to place them just outside because I didn't want the transaction to rollback for an event sending failure. But it's up to you really!