php-solution / notification
用于创建通知功能的库
v0.1
2017-03-30 06:54 UTC
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-09-14 18:09:49 UTC
README
通知组件帮助开发者创建发送通知系统的功能。
概念
逻辑部分
- 上下文
- 管理器
- 扩展
- 类型
- 规则
- 通知器
主要流程
- 客户端创建上下文并设置通知的一些参数,指定通知类型(字符串名称或对象)并将此信息发送给管理器
$type = new NotificationType();
$context = new Context(['parameter' => 'parameter value']);
$notificationManager->notifyType($type, $context);
或
$context = new Context(['parameter' => 'parameter value']);
$notificationManager->notifyType(NotificationType::getName(), $context);
- 管理器通过扩展准备类型和上下文(如果为管理器指定了扩展)
- 类型构建规则/规则(为通知器的一些简单信息)
- 通知器接受规则(参数)并发送实际通知。例如:Email 通知器接受发送电子邮件的参数(规则)(发件人,收件人,抄送,文本)并通过 smtp 邮件发送
管理器
这是一个发送通知的服务,有2个公共方法用于发送通知
- notify(string $name, Context $context = null) - 将从类型注册表中获取类型
- notifyType(TypeInterface $type, Context $context = null) - 使用接受的类型
扩展
实现准备类型、上下文信息以构建规则的功能
上下文
类型参数的一些值对象
类型
规则构建器
规则
通知器参数的一些值对象
通知器
实现实际发送通知的功能
安装
- 添加到您的 composer.json 文件中
"require": {
...
"php-solution/notification": "dev-master",
...
}
- 运行
composer update php-solution/notification