auroraextensions / notificationservice
通过 XML 发布后端通知。
Requires
- php: >=7.1
- ext-dom: *
- magento/framework: 102.*.*
- magento/module-admin-notification: 100.*.*
- magento/module-backend: 101.*.*
This package is auto-updated.
Last update: 2024-09-17 08:58:21 UTC
README
描述
Magento 提供的后端通知系统缺乏强大的功能,如自动发布和发现。因此,许多扩展供应商未能有效地利用它进行重要公告,例如 API 破坏性发布、EOL 通知或特定扩展功能的弃用,这可能导致透明度问题。
为了解决这个问题,如果能够在模块中添加一个 XML 文件,其中包含要发布的通知,而其余的由通知系统处理,那岂不是很好?这将消除对特定通知模型的依赖和数据补丁,并且不需要升级设置即可运行以发布新通知。
总之:使用起来应该非常简单。
安装
composer require auroraextensions/notificationservice
配置
配置只需将 notifications.xml
文件添加到模块的 etc
目录即可。
示例
下面是一个示例 notifications.xml
。有关架构信息,请参阅 XML 架构。
<?xml version="1.0"?> <!-- /** * notifications.xml */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:AuroraExtensions_NotificationService/etc/notifications.xsd"> <releases group="notificationservice"> <release version="1.0.0"> <notifications> <notification index="0" severity="notice"> <title translate="true">v1.0.0 low-priority notification title</title> <description translate="true">This is a low-priority notification about v1.0.0.</description> </notification> <notification index="1" severity="major"> <title translate="true">v1.0.0 high-priority notification title</title> <description translate="true">This is a high-priority notification about v1.0.0.</description> <link>https://www.example.com/</link> </notification> </notifications> </release> <release version="1.0.1"> <notifications> <notification index="0" severity="minor"> <title translate="true">v1.0.1 medium-priority notification title</title> <description translate="true">This is a medium-priority notification about v1.0.1.</description> </notification> </notifications> </release> </releases> </config>
XML 架构
为了简化,XSD 提供了一组最小元素和属性类型。
与许多 Magento XML 配置一样,<config>
是根节点。所有其他节点都是 <config>
的后代。
<releases>
<releases>
节点是外部节点,有一个(1)属性,group
。group
属性的值应该是通用的唯一值,以防止不想要的合并。它是一个 array
类型,并且应该只包含 <release>
节点。
<release>
<release>
节点有一个(1)属性,version
。version
属性的值应该是与特定通知(s)关联的模块版本。它应该只包含一个(1)<notifications>
节点。
<notifications>
<notifications>
节点是一个 array
类型节点,并且应该只包含 <notification>
节点。它没有相关的属性。
<notification>
<notification>
节点描述了特定通知的各种组件,并有两个(2)属性,index
和 severity
。index
属性的值必须是 int
类型,表示通知在通知结果数组中的位置。severity
属性映射到 MessageInterface
中定义的级别 [1],并且必须是以下之一
critical
major
minor
notice
它应该包含以下类型之一的一个(1)节点
<title>
<description>
<link>
(可选)
<title>,<description>
<title>
和 <description>
节点构成了通知的主体。<title>
节点包含在通知的第一行显示的文本,而 <description>
节点包含通知的主体。这两个节点都提供了一个(1)属性,translate
。translate
属性的值始终应该是 true
,否则简单地省略属性以防止翻译。
<link>
该 <link>
节点包含一个指向 详细阅读 链接的 URL。此节点是可选的,可以省略。它没有关联的属性。