dev-master
9999999-dev https://github.com/JimmyTournemaine/JTNotificationBundleNotification system integration
MIT
The Requires
notification
Notification system integration
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)
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(), ); // ... } // ... } ```
# 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
php bin/console doctrine:schema:update --force
<?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']) ; } }
$this->get('jt_notification.helper')->send(PostType::class, $options, $users);
{% if is_granted('IS_AUTHENTICATED_REMEMBERED') %} {{ jt_notification_render() }} {% endif %}
You can edit the rendering of your notifications by override JTNotification::macros.html.twig like it is described in the Symfony documentation, (*5)
Notification system integration
MIT
notification