Example (2): E-Mail notification on changes
This is just a short tutorial which shows following features:
- Create a list of E-Mail recipients, named it
watchers - on change or transition (Statemachine Workflow) send an email to every
watcher
1. Create a property watchers in Ticket class
In our Ticket-class (Ticket.php) we add a new property named watchers which is an array of Emails:
OK, now we already have <input/>s in our view:

Add- and remove-buttons work out the box.
2. afterUpdate and afterChangeState hooks
We can override both functions afterUpdate() and afterChangeState(), prepare a subject and send an email:
3. Finally retrieve watchers and send email
There are several ways to implement such, this is just one:
Test and results
- Reload a
Ticket-record add some Watchers - Make some changes and save. Your watchers will receive an email.
- Change the state using the Statemachine Workflow. Your watchers will get another email.
