dft/silverstripe-notifier
Composer 安装命令:
composer require dft/silverstripe-notifier
包简介
Configurable notifications system for sending notifications based on data object activity
README 文档
README
Module to allow creation of custom notifications for object changes that can be managed via the admin.
Install
Install this module via composer:
composer require dft/silverstripe-notifier
Once installed run dev/build to add additional database tables
Configuration and Setup
Once installed, you will have to register the DataObjects you want
to be monitored for notification with Notifier. This can be done
via fairly simple config:
---
Name: notificationsconfig
---
# allow configuring of notifications to users and a custom page type
DFT\SilverStripe\Notifier\Notifier:
registered_objects:
- SilverStripe\Security\Member
- App\Model\MyCustomPage
Once this configuration is added (and you flush the cache), navigate to SiteConfig ("Settings" in the admin).
Now there will be a "notifications" tab allowing you to add new notifications
Adding notifications
When you add a new notification you will be able to choose the object to monitor (from the list of registered objects above). You can then also choose:
StateCreated: Should a notification be sent on object creation
StateUpdated: Should a notification be sent if an object is ever updated
StateDeleted: Should a notification be sent if an object is deleted
Adding Rules (optional)
You can also add more granular rules for each notification. These allow you to specify:
FieldName: The name of the data field on the object that will be checked
Value: If set, when an object has a field that is set to this value, send
a notification
WasChanged: If you leave Value blank, then you can check WasChanged and
then any change to this field will send a notification
Disallow Notification Rules (optional)
You can disallow notification rules on specific notifications
via the disallow_rules config variable. This needs to be a
list of rule classnames that this notification type will not
allow. This can be set in YML as follows:
---
Name: notificationsconfig
---
# Disallow basic notification rule
DFT\SilverStripe\Notifier\Model\Notification:
disallow_rules:
- DFT\SilverStripe\Notifier\Model\Notification\NotificationRule
Adding Notification Types
Once you have specified an object to monitor and what will trigger notifications you then need to specify how these notifications will be sent.
By default this module includes an EmailNotification, which will send an email
to the desired recipient using the provided subject and content.
You can add multiple versions of the each NotificationType to the same
Notification (for example, if you want to email multiple people in the event
of a change).
Disallow Notification Types (optional)
You can disallow notification types on specific notifications
via the disallow_types config variable. This needs to be a
list of rule classnames that this notification type will not
allow. This can be set in YML as follows:
---
Name: notificationsconfig
---
# Disallow email notification type
DFT\SilverStripe\Notifier\Model\Notification:
disallow_types:
- DFT\SilverStripe\Notifier\Types\EmailNotification
Content Rendering
Notification content (and email subjects) support using SilverStripe variables When a notification is sent, the context with regards to variables will be the current object that is being monitored.
EXAMPLE If sending an email when a new Member is created, you can add
{$FirstName}, {$Surname}, {$Email} etc to your Content area, and these
will be rendered using the newly created Member.
New Notification Types
The system is designed to fairly easily add new notification types (for example
SMS notifications) You simply have to extend NotificationType and add your own
send method to handle sending the notification.
Dynamic senders and recipients
Instead of using a predefined sender and recipients, you can instead specify fields on the monitored object to use.
Before you can do this though, you have to inform Notifier that you want to use custom fields. For example, if you have the following object:
class MyMonitoredObject extends DataObject { private static $db = [ 'Sender' => 'Email', 'Recipient' => 'Email' ]; private static $extensions = [ 'DFT\SilverStripe\Notifier' ]; }
You can add custom config:
DFT\SilverStripe\Notifier\Types\NotificationType: alt_from_fields: MyMonitoredObject: - Sender alt_recipient_fields: MyMonitoredObject: - Recipient
Now, when you log into your admin area and visit:
Settings > Notifications and setup a new notification
you will see alternate dropdowns that let you select the
field you would like yo use.
dft/silverstripe-notifier 适用场景与选型建议
dft/silverstripe-notifier 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 123 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「notifications」 「silverstripe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dft/silverstripe-notifier 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dft/silverstripe-notifier 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dft/silverstripe-notifier 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova package that adds a notification feed in your Nova app.
Analytics chooser extensions for site settings.
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
CitaNZ's SilverStripe picture object and field for SilverStripe 4
统计信息
- 总下载量: 123
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2025-01-13