PHP code example of aldaflux / notification-bundle
1. Go to this page and download the library: Download aldaflux/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/ */
aldaflux / notification-bundle example snippets
class MyController extends Controller
{
...
public function sendNotification(Request $request)
{
$manager = $this->get('mgilet.notification');
$notif = $manager->createNotification('Hello world!');
$notif->setMessage('This a notification.');
$notif->setLink('https://symfony.com/');
// or the one-line method :
// $manager->createNotification('Notification subject', 'Some random text', 'https://google.fr/');
// you can add a notification to a list of entities
// the third parameter `$flush` allows you to directly flush the entities
$manager->addNotification(array($this->getUser()), $notif, true);
...
}