Download the PHP package sokil/notification-bundle without Composer
On this page you can find all versions of the php package sokil/notification-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package notification-bundle
Notification Bundle
Installation
Use composer to install dependency:
Add bundle to AppKernel:
Add roles to role hierarchy in file ./app/config/security.yml
:
Add routing to ./app/config/routing.yml
:
Creating messages
Message builder
First we need to create message builder, which optain some dependencies from container and build message instances.
It must extend \Sokil\NotificationBundle\MessageBuilder\AbstractBuilder
class:
This builder must be registered as service in container and tagged by notification.message_builder
:
This service will build messages with type someMessages
for transport email
. One
message may be used for different transports. In this case just add another tag:
Message builder collection
Collection holds number of different messages. Collection used to group
messages. It must extends class Sokil\NotificationBundle\MessageBuilder\BuilderCollection
.
To register new collection, define new service:
There is already collection with name default
, defined as service notification.message_builder_collection
.
To add message builder to collection, set collectionName
attribute of builder's notification.message_builder
tag:
If collectionName
not specified, builder registered in default
collection.
To get builder from collection:
If collection's service not defined, it will be created for you automatically, so
you need only define collectionName
in message builder's tag, and then get
collection's service from container
by id notification.message_builder_collection.{SOME_COLLECTION_NAME}
.
Schema of notification
Available transports
Configuring custom transport
Preview
To enable preview, add routing to your ./app/config/routing.yml
:
Now preview of mails available at route /notification/preview
.
To access this route, you reed to have ROLE_NOTIFICATION_MAIL_PREVIEW
.
For example we have message builder described in service:
To see preview, open next URL in your browser: