php-solution / notification
Library for create notify functionality
Installs: 2 687
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
Requires (Dev)
- php: >=7.1
- symfony/event-dispatcher: >=3.0
- symfony/options-resolver: >=3.0
Suggests
- symfony/event-dispatcher: for use event dispatcher extension
- symfony/options-resolver: for use configure Context extension
This package is auto-updated.
Last update: 2024-11-14 18:25:56 UTC
README
Notification component helps developer to create functionality for send notification system.
Concept
Parts of logic:
- Context
- Manager
- Extension
- Type
- Rule
- Notifier
Main Flow:
- Client create Context and set some parameter for notification, specify Type of notification(string name or object) and send this info to Manager
$type = new NotificationType();
$context = new Context(['parameter' => 'parameter value']);
$notificationManager->notifyType($type, $context);
or
$context = new Context(['parameter' => 'parameter value']);
$notificationManager->notifyType(NotificationType::getName(), $context);
- Manager prepare Type and Context via Extension(if Extension is specified for Manager)
- Type build Rule/Rules(some simple info for Notifier)
- Notifier accept Rule(parameters) and send real notification. For example: Email Notifier accept parameters(Rule) for email sending(from, to, cc,text) and send via smtp mail
Manager
This is a service for send notification, has 2 public methods for send notification:
- notify(string $name, Context $context = null) - will get Type from TypeRegistry
- notifyType(TypeInterface $type, Context $context = null) - use accepted Type
Extension
Implements functionality for prepare Type, Context info before build Rules
Context
Some value object of parameters for Type
Type
Rule builder
Rule
Some value object of parameters for Notifier
Notifier
Implements functionality for real notification sending
Installing
- Add to your composer.json
"require": {
...
"php-solution/notification": "dev-master",
...
}
- run:
composer update php-solution/notification