PHP code example of irishdan / notification-bundle
1. Go to this page and download the library: Download irishdan/notification-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
irishdan / notification-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new IrishDan\NotificationBundle\NotificationBundle(),
);
}
/** $user NotifiableInterface */
$user = $this->getUser();
/** $notification NotificationInterface */
$notification = new NewMemberNotification();
// The notification.manager service is used to send notifications
$this->get('notification.manager')->send($notification, $user);
// You can send to multiple users also.
$this->get('notification.manager')->send($notification, [$user1, $user2]);
// You can pass extra data into the notification also
// This will be available in the data array
// and also in twig templates as {{ data.date }}
$data = [
'date' => new \DateTime(),
];
$this->get('notification.manager')->send($notification, $user, $data);