2017 © Pedro Peláez
 

symfony-bundle notification-bundle

Notification system integration

image

jimmytournemaine/notification-bundle

Notification system integration

  • Tuesday, September 6, 2016
  • by jimtournem
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Installation

SensioLabsInsight, (*1)

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*2)

$ composer require jimmytournemaine/notification-bundle "master"

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*3)

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*4)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new JT\NotificationBundle\NotificationBundle(),
        );

        // ...
    }

    // ...
}
```

Step 3: Routing

# app/config/routing.yml

jt_notification:
    resource: "@JTNotificationBundle/Resources/config/routing.yml"
# app/config/config.yml

doctrine:
    orm:
        resolve_target_entities:
            JT\NotificationBundle\Model\NotifyableInterface: AppBundle\Entity\User

Step 5: Update your database

php bin/console doctrine:schema:update --force

Create your notification type

<?php
namespace AppBundle\Notification\Type;

use JT\NotificationBundle\Builder\NotificationBuilderInterface;
use JT\NotificationBundle\Notification\Type\AbstractType;

class PostType extends AbstractType
{

    public function buildNotification(NotificationBuilderInterface $builder, array $options)
    {
        $builder
            ->addIcon('bell', array(
                'type' => 'icon',
                'prefix' => 'fa',
                'alt' => '+'
            ))
            ->addTitle('notification.post.title', array(
                'trans_parameters' => array('%name%' => 'Jimmy')
            ))
            ->addDescription('notification.post.description', array(
                'trans_domain' => "MyDomain"
            ))
            ->addLink('homepage', array(
                'type' => 'route'
            ))
            ->addUsers($options['users'])
        ;
    }
}

Send your notification

$this->get('jt_notification.helper')->send(PostType::class, $options, $users);

Display the user's notifications

{% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
    {{ jt_notification_render() }}
{% endif %}

Override the rendering

You can edit the rendering of your notifications by override JTNotification::macros.html.twig like it is described in the Symfony documentation, (*5)

The Versions

06/09 2016

dev-master

9999999-dev https://github.com/JimmyTournemaine/JTNotificationBundle

Notification system integration

  Sources   Download

MIT

The Requires

 

notification