ineph / notification-bundle
一个简单的 Symfony 5 用户通知组件
dev-master / 0.1.0.x-dev
2022-05-11 15:07 UTC
Requires
- doctrine/doctrine-bundle: *
- symfony/framework-bundle: ^4.0 || ^5.0
- twig/twig: *
This package is auto-updated.
Last update: 2024-09-11 20:10:24 UTC
README
以高效的方式创建和管理通知。
Symfony 支持
- 5.x
现在支持 SYMFONY FLEX!
3.0 版本现已发布。
功能
- 易于设置
- 易于使用
- 强大的通知管理
- 简单的 Twig 渲染方法
- 完全可定制
- 多种可通知实体
- 无冗余依赖(要求少)
注意:目前只支持 Doctrine ORM。
从 3.x 升级
自定义通知实体使用
如果您使用自定义通知实体,您必须从 doctrine 配置中删除 resolve_target_entities
指令并添加一个配置文件。
示例
在按照 #39 添加自定义通知类后,只需添加一个配置文件
config/packages/ineph_notification.yaml
ineph_notification: notification_class: App\Entity\MyCustomNotification
安装 & 使用
此组件可在 packagist 上找到。
将 notification-bundle 添加到您的项目
$ composer require ineph/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