Array
(
[0] => Notifier\Model\Entity\Notification Object
(
[id] => 3
[template] => newUser
[vars] => {"loggedin_user":"Justin DEDACTED","new_user":"Rex DEDACTED"}
[user_id] => 1
[state] => 1
[created] => Cake\I18n\Time Object
(
[time] => 2016-01-05T05:09:38+0000
[timezone] => UTC
[fixedNowTime] =>
)
[modified] => Cake\I18n\Time Object
(
[time] => 2016-01-05T05:09:38+0000
[timezone] => UTC
[fixedNowTime] =>
)
[tracking_id] => YIjHeLBdam
[[new]] =>
[[accessible]] => Array
(
[template] => 1
[vars] => 1
[tracking_id] => 1
[user_id] => 1
)
[[dirty]] => Array
(
)
[[original]] => Array
(
)
[[virtual]] => Array
(
[0] => title
[1] => body
[2] => unread
[3] => read
)
[[errors]] => Array
(
)
[[repository]] => Notifier.Notifications
)
}
@justinatack as you can see here (https://github.com/cakemanager/cakephp-notifier/blob/master/src/Model/Entity/Notification.php#L77-L121) the notification-entity contains the virual fields. So, to get the title you use $notification->title
.
The notifier plugin works with templates, and I think I didn't explain that clear enough in the docs. Templates are NOT the same as templates in CakePHP itself. You can register templates inside your config/bootstrap.php
for example:
$notificationManager->addTemplate('newBlog', [
'title' => 'New blog by :username',
'body' => ':username has posted a new blog named :name'
]);
(templates are stored in the Configure-class of Cake)
You can 'use' this template when you create a notification:
$notificationManager->notify([
'users' => [1,2],
'recipientLists' => ['administrators'],
'template' => 'newBlog', // <--------------- HERE YOU GO
'vars' => [
'username' => 'Bob Mulder',
'name' => 'My great new blogpost'
]
]);
Docs: https://github.com/cakemanager/cakephp-notifier#templates
I hope this made sense, else let me know ;)
@akkaweb This is an example how to work with events to make your plugin work with the notifier.
First of all: read more about events here: http://book.cakephp.org/3.0/en/core-libraries/events.html
This example shows you what to do in your model. Lets call your event in your case 'Model.Feedback.afterSave'. This is the only change you should do at the side of your plugin. Whats done now, is that when a feedback item has been sent, the event is called.
So what we got to do now is use the event to notify.
For that we need a listener. If you see that example, it should be clear enough you have to catch your event, and use the Notifier...
afterSave
event that is fired by the Model, all I had to do was create src/Event/FeedbackListener.php
and look into the Fired Model Event for the Feedback Save Event