aldaflux/notification-bundle

A simple Symfony 5 bundle for user notifications, forked from mgilet/notification-bundle

Installs: 12

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 57

Type:symfony-bundle

v5.1.0 2021-09-06 17:38 UTC

This package is auto-updated.

Last update: 2024-03-06 22:59:45 UTC


README

An easy yet powerful notification bundle for Symfony

Latest Stable Version Latest Unstable Version Total Downloads License

SensioLabsInsight

mgilet/notificationBundle

Create and manage notifications in an efficient way.

Symfony support :

  • 4.3
  • 5.x

NOW SUPPORTS SYMFONY FLEX !

Version 3.0 out now.

Features

  • Easy setup
  • Easy to use
  • Powerful notification management
  • Simple Twig render methods
  • Fully customizable
  • Multiple notifiables entities
  • No bloated dependencies (little requirements)

Notice: Only Doctrine ORM is supported for now.

Upgrade from 3.x

Custom Notification entity usage

If you use a custom Notification entitiy you must remove the resolve_target_entities directive from the doctrine configuration and add a configuration file.

Example

After adding the customized notification class as in #39 just add a configuration file

config/packages/mgilet_notification.yaml

mgilet_notification:
  notification_class: App\Entity\MyCustomNotification

Installation & usage

This bundle is available on packagist.

Add notification-bundle to your project :

$ composer require mgilet/notification-bundle

See documentation for next steps

Basic usage

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);

      ...
    }

Translations

For now this bundle is only translated to de, en, es, fa, fr, it, nl, pt_BR, pl.

Help me improve this by submitting your translations.

Community

You can help make this bundle better by contributing (every pull request will be considered) or submitting an issue.

Enjoy and share if you like it.

Licence

MIT