PHPackages                             jamesi/notification-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. jamesi/notification-bundle

ActiveSymfony-bundle[Mail &amp; Notifications](/categories/mail)

jamesi/notification-bundle
==========================

Create an email and on-site notification/alerts system for your users

v0.1.0(11y ago)136MITPHP

Since Nov 20Pushed 7y ago1 watchersCompare

[ Source](https://github.com/jamesisaac/JamesiNotificationBundle)[ Packagist](https://packagist.org/packages/jamesi/notification-bundle)[ Docs](https://github.com/jamesisaac/JamesiNotificationBundle)[ RSS](/packages/jamesi-notification-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

NotificationBundle
==================

[](#notificationbundle)

This Symfony bundle allows the creation of a *notification system* for registered members of a site. Similar to that seen on sites like Facebook.

A **Notification** corresponds to an event which happened on the site which the user should be made aware about. The Notification class contains the logic to build the views needed for the Alert and email which will be sent to the user.

An **Alert** is an on-site notification - you should implement some section on the site where the user can see their history of Alerts, and probably let them see their unseen Alert count at all times.

The **Notifier**, when provided with a Notification, may fire an email and/or Alert, depending on the user's preferences (must be implemented through `NotifiableInterface`).

Usage
-----

[](#usage)

- Add the bundle to your composer.json (note: this bundle hasn't reached a stable version yet:

```
{
    "require": {
        "jamesi/notification-bundle": "dev-master"
    }
}
```

- Add the bunlde to your AppKernel

```
    public function registerBundles()
    {
        $bundles = array(
            ...
            new Jamesi\NotificationBundle\JamesiNotificationBundle(),
    }
```

- Make your User class implement the `NotifiableInterface`:

```
    public function getNotificationName()
    {
        // Who should the email be addressed to?
        return $this->getUsername();
    }

    public function getNotificationEmail()
    {
        // Who should the email be addressed to?
        return $this->getEmail();
    }

    public function acceptsNotificationAlert($type)
    {
        // Implement logic here for which on-site alerts the user wants
        return true;
    }

    public function acceptsNotificationEmail($type)
    {
        // Implement logic here for unsubscribing from types of email notification
        return true;
    }
```

- Create an entity which extends the provided Alert entity, give it an ID and an entity type (i.e. your User implementation) for the $user ManyToOne relationship

```
