Download the PHP package symfony-bro/notification-core without Composer
On this page you can find all versions of the php package symfony-bro/notification-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download symfony-bro/notification-core
More information about symfony-bro/notification-core
Files in symfony-bro/notification-core
Package notification-core
Short Description Schedule bundle
License
Informations about the package notification-core
Introduction
This library is provided to abstract transport layer of notification process.
Architecture
Transport layer
The main abstraction of the transport layer is
\SymfonyBro\NotificationCore\Model\NotificationManagerInterface
with only method notify(NotificationInterface $notification)
.
The idea is that we should create a notification object for some event and send it
with notification manager. So, client code knows nothing about how notification will be send.
We've created an abstract implementation for this interface —
\SymfonyBro\NotificationCore\Model\AbstractNotificationManager
.
Internally it delegates job to formatter and driver objects.
Driver
Driver object implements \SymfonyBro\NotificationCore\Model\DriverInterface
and responsible for sending a message. Message is another object implements
\SymfonyBro\NotificationCore\Model\MessageInterface
related to a specific driver.
For example we have SwiftMailerDriver out of the box and it can send SwiftMailerMessage.
But where do we get a message object?
Formatter
There is formatter object which implements \SymfonyBro\NotificationCore\Model\FormatterInterface
.
The only purpose of formatter is creating a message object from a notification object.
Examples
Say, we have to send an email to the client if he makes new order. Suppose you already have some observer pattern implementation and you have listener for new order event. First we should create new notification class for this event:
It should contains all required information, in example above it receives an
Order
object and we suppose that Order
contains Customer
object
with some kind of contact information: $order->getCustomer()->getEmail()
.
Then we have to create a formatter object: