mgilet / notification-bundle
一个简单的 Symfony 3 用户通知包
4.0
2021-01-07 07:36 UTC
Requires
- doctrine/doctrine-bundle: *
- symfony/framework-bundle: ^2.7 || ^3.0 || ^4.0 || ^5.0
- twig/twig: *
README
以高效的方式创建和管理通知。
Symfony 支持
- 2.7.x (包版本 2.x)
- 2.8.x (包版本 2.x)
- 3.x
- 4.x
现在支持 Symfony Flex !
3.0 版本现已发布。
功能
- 易于设置
- 易于使用
- 强大的通知管理
- 简单的 Twig 渲染方法
- 完全可定制
- 多个可通知实体
- 无冗余依赖(要求少)
注意:目前仅支持 Doctrine ORM。
从 3.x 升级
自定义通知实体使用
如果您使用自定义通知实体,则必须从 doctrine 配置中删除 resolve_target_entities
指令,并添加一个配置文件。
示例
如 #39 中所述添加自定义通知类后,只需添加一个配置文件
config/packages/mgilet_notification.yaml
mgilet_notification: notification_class: App\Entity\MyCustomNotification
安装 & 使用
此包可在 packagist 上找到。
将 notification-bundle 添加到您的项目中
$ composer require mgilet/notification-bundle
有关下一步操作,请参阅 文档
基本使用
class MyController extends Controller { ... public function sendNotification(Request $request) { $manager = $this->get('mgilet.notification'); $notif = $manager->createNotification('Hello world!'); $notif->setMessage('This a notification.'); $notif->setLink('https://symfony.com.cn/'); // or the one-line method : // $manager->createNotification('Notification subject', 'Some random text', 'https://google.fr/'); // you can add a notification to a list of entities // the third parameter `$flush` allows you to directly flush the entities $manager->addNotification(array($this->getUser()), $notif, true); ... }
翻译
目前此包仅翻译为 de、en、es、fa、fr、it、nl、pt_BR、pl。
通过提交您的翻译来帮助我改进。
社区
您可以通过贡献(每个拉取请求都将被考虑)或提交问题来帮助改进此包。
如果您喜欢,请享受并分享。
许可证
MIT