kalitics/notification-bundle

Add notifications to symfony app

Installs: 256

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Forks: 0

Type:symfony-bundle

2.0.13 2021-10-05 09:25 UTC

This package is auto-updated.

Last update: 2024-04-05 13:07:32 UTC


README

Notifications management

Installation

Require the bundle using

composer require kalitics/notification-bundle

Create the file config/packages/kalitics_notification.yaml with the following content :

kalitics_notification:

Add a new path for template in config/packages/twig.yaml

twig:
    ...
    paths:
        '%kernel.project_dir%/vendor/kalitics/notification-bundle/src/Ressources/views': kaliticsNotification

Add a new entry in config/bundles.php to register the new bundle

Kalitics\NotificationBundle\KaliticsNotificationBundle::class => ['all' => true],

Create a new file config/routes/kalitics_notification.yaml

_kalitics_notification:
  resource: '@KaliticsNotificationBundle/Ressources/config/routes.xml'
  prefix: /kalitics/notifications/

Add the following in the application header to display the notifications icon

{{ include('@KaliticsNotification/icon/notifications_container.html.twig') }}

Add the following in the application layout to have the detail modal

{{ include('@KaliticsNotification/_includes/_modal.html.twig') }}

The management of notification Subscriptions is display using the following controller :

{{ render(path('kalitics_notification_subscription_manage', {'id' : app.user.id})) }}

important

There must be an entity User such as : `App\Entity\User\User`

There must be an entity Group such as : `App\Entity\Security\Group`

Database configuration

To get properly configured, the database need some informations such as Notification type and difusion lists using the following tables :

ntf_notification_subscription_included_groups
ntf_notification_subscription_included_members
ntf_notification_subscription_excluded_members

Usage

To trigger a notification,

$this->notificationService->generateNotification(NotificationTypeEnum::CREATE_USER);
//Where NotificationTypeEnum::CREATE_USER is the notification slug configured in database