Download the PHP package hadesarchitect/notification-bundle without Composer
On this page you can find all versions of the php package hadesarchitect/notification-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hadesarchitect/notification-bundle
More information about hadesarchitect/notification-bundle
Files in hadesarchitect/notification-bundle
Package notification-bundle
Short Description Event-driven notification bundle for Symfony 2 environment.
License MIT
Informations about the package notification-bundle
HadesArchitect Notification Bundle
Event-driven notification bundle for Symfony 2 environment. Provides convenient way to manage user notifications in applications, for example to warn administrators about important events like user registration or notify users about any significant things for them like 'your order has been sent'. At that moment supports only swiftmailer as a notification channel, but it could be easily extended. Visual part could be rendered by any supported template engine like twig.
Installation
Install through composer:
First step: require bundle
Second step: enable bundle
Usage
Example
I'd like to receive notifications when someone comments my posts, assuming I've used FOSCommentBundle for commentaries functionality. To do it, I should make two simple steps:
- Add a template for a notification
- Configure handler in app/config/config.yml
First of all, I need to write a template which would be rendered and send to me. I'll use a twig as a template engine. Every template will automatically take some arguments from handler, at that moment it's an event, event name and receiver information. Let me introduce you tiny twig template.
After that, I should configure event handler.
That's all! Don't forget to ensure swiftmailer configuration because mail sending could be not configured or disabled in development environment.
Configuration
After initial setup you should configure the bundle in appropriate way. Normally it could be done by some changes in app/config/config.yml or if you would like to keep user notifications in separate file you should create a new file, f.e. app/config/notifications.yml and include it in the config.yml (imports: [{resource: notifications.yml}]).
Typical configuration
A typical way is to specify some data for handlers: expected event, receiver's data, subject and template
Full configuration
Parameters
Parameters which you could override:
- ha_notification.default_subject - Subject for notifications
- ha_notification.view.default_template - Template for letter body
- ha_notification.handler.default_class - Handler class
- ha_notification.channel.swiftmailer_class - Default class for swiftmailer notification channel
Todo
- Describe ways to extend bundle
- Add more tests
- Add possibility to dinamically determine receiver's address
- Add possibility to throw notifications directly, not only through event handlers
- Add possibility to bypass any services and parameters to templates, instead of using twig globals