bupy7/yii2-snotify

此包已废弃,不再维护。未建议替代包。

Snotify是服务器端实现,不依赖客户端的用户通知扩展。

安装: 58

依赖: 0

建议者: 0

安全: 0

星标: 4

关注者: 1

分支: 2

开放问题: 0

类型:yii2-extension

dev-master 2016-02-08 19:40 UTC

This package is auto-updated.

Last update: 2020-04-11 02:19:17 UTC


README

Snotify是服务器端实现,不依赖客户端的用户通知扩展。

安装

通过composer安装此扩展是首选方式。

运行以下命令之一

php composer.phar require --prefer-dist bupy7/yii2-snotify "*"

或者在composer.json文件的require部分添加以下内容

"bupy7/yii2-snotify": "*"

使用

在配置文件中将模块注册到modules部分

[
    'modules' => [
        ...
        
        'snotifymodule' => [
            'class' => 'bupy7\notify\ss\Module',
        ],

        ...
    ],
],

在配置文件的bootstrap部分添加snotifymodule

[
    'bootstrap' => [
        ...
        
        'snotifymodule',
    
        ...
    ],
],

在配置文件的components部分注册snotify管理器

[
    'components' => [
        ...

        'snotify' => [
            'class' => 'bupy7\notify\ss\components\Manager',
        ],
        
        ...
    ],
],

您可以根据需要重命名组件和模块。

运行迁移

php ./yii migrate/up --migrationPath=@bupy7/notify/ss/migrations

添加通知消息

$userId = Yii::$app->user->id;
$body = 'Example of text message';
$title = 'Example of title message';
Yii::$app->snotify
    // success notify type
    ->addSuccess($userId, $body, $title)
    // danger notify type
    ->addDanger($userId, $body, $title)
    // info notify type
    ->addInfo($userId, $body, $title)
    // warning notify type
    ->addWarning($userid, $body, $title);

完成!您的通知已添加到{{%notification}}表中。

配置

模块

[
    'modules' => [
        ...
        
        'snotifymodule' => [
            'class' => 'bupy7\notify\ss\Module',
            'tableName' => '{{%notification}}', // table name with notification messages
            'db' => 'db', // database connection component config or name
        ],

        ...
    ],
],

许可

yii2-snotify基于BSD 3-Clause License发布。