aldaflux/notification-bundle

一个简单的 Symfony 5 扩展包,用于用户通知,由 mgilet/notification-bundle 分支而来

安装: 12

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 57

类型:symfony-bundle

v5.1.0 2021-09-06 17:38 UTC

This package is auto-updated.

Last update: 2024-09-07 00:12:23 UTC


README

一个简单而强大的 Symfony 通知扩展包

Latest Stable Version Latest Unstable Version Total Downloads License

SensioLabsInsight

mgilet/notificationBundle

以高效的方式创建和管理通知。

Symfony 支持

  • 4.3
  • 5.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。

通过提交您的翻译来帮助我改进。

社区

您可以通过贡献(每个 pull request 都会考虑)或提交问题来帮助改进此扩展包。

喜欢就享受并分享。

许可

MIT