-
Notifications
You must be signed in to change notification settings - Fork 38
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
Create a behavior to send out auto notifications #23
Comments
Sorry for the delay @suhaboncukcu. What would be the sense of a behavior? If you want to keep your controllers clean (I agree with that :)), you can still add your code to send notifications within events in your model right? |
As I can code my own notifications plugin :) I thought it would be something nice working out of the box. |
Would be kind of 'double' right? ;) Can you show me an example how it would work better in your situation? I am curious! |
I have a system that people joins to some channels and they get mails each time something added to their channels. I installed the notifications plugin to set up internal notifications (or with adapters may be, to be able to send to different places). After configuring the plugin, I should run the component each time I need a notification sent, which could be at different endpoints. So I really don't want to do that since we are working as several people on the project and it could lead some conflicts. So, I should create en event listener and fire an event to handle this notification sending which I would use the utility class since I'm on model level. If I had a behavior instead; I could just call that behavior within my model class. I can -of course- create a behavior with the utility class. Only if I don't have a behavior class waiting ready for me. :) |
I don't have a behavior class waiting for you unfortunately. Can you set up a PR? I think you're right that the behavior should use the Utility class heavily... |
surely, as soon as I have time. I will send a PR. Which I think would describe my case better as well. |
👍 Looking forward to your suggestion! Good luck! |
As you know keeping controllers clean and implementing the data related logic into model level is a better approach for CakePHP in a few different ways.
So, since the notifications are created with templates, I often find myself using variables from my entity just after saving it. For example; I want to notify all users when I add a new record to my posts. So I suggest thinking about something like below:
The text was updated successfully, but these errors were encountered: