jamesi/notification-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jamesi/notification-bundle

最新稳定版本:v0.1.0

Composer 安装命令:

composer require jamesi/notification-bundle

包简介

Create an email and on-site notification/alerts system for your users

README 文档

README

This Symfony bundle allows the creation of a notification system for registered members of a site. Similar to that seen on sites like Facebook.

A Notification corresponds to an event which happened on the site which the user should be made aware about. The Notification class contains the logic to build the views needed for the Alert and email which will be sent to the user.

An Alert is an on-site notification - you should implement some section on the site where the user can see their history of Alerts, and probably let them see their unseen Alert count at all times.

The Notifier, when provided with a Notification, may fire an email and/or Alert, depending on the user's preferences (must be implemented through NotifiableInterface).

Usage

  • Add the bundle to your composer.json (note: this bundle hasn't reached a stable version yet:
{
    "require": {
        "jamesi/notification-bundle": "dev-master"
    }
}
  • Add the bunlde to your AppKernel
    public function registerBundles()
    {
        $bundles = array(
            ...
            new Jamesi\NotificationBundle\JamesiNotificationBundle(),
    }
  • Make your User class implement the NotifiableInterface:
    public function getNotificationName()
    {
        // Who should the email be addressed to?
        return $this->getUsername();
    }

    public function getNotificationEmail()
    {
        // Who should the email be addressed to?
        return $this->getEmail();
    }

    public function acceptsNotificationAlert($type)
    {
        // Implement logic here for which on-site alerts the user wants
        return true;
    }

    public function acceptsNotificationEmail($type)
    {
        // Implement logic here for unsubscribing from types of email notification
        return true;
    }
  • Create an entity which extends the provided Alert entity, give it an ID and an entity type (i.e. your User implementation) for the $user ManyToOne relationship
<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Jamesi\NotificationBundle\Entity\Alert as BaseAlert;

/**
 * @ORM\Entity
 * @ORM\Table(name="alert")
 */
class Alert extends BaseAlert
{
    /**
     * @var int
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @var User
     * @ORM\ManyToOne(targetEntity="User")
     */
    protected $user;
}
  • Configure the bundle in app/config/config.yml:
jamesi_notification:
    alert_class: AppBundle\Entity\Alert
    from_email:
        address: myapp@example.com
        sender_name: My App Name
  • Start creating Notification subclasses in your bundle (see FooNotification for an example)

  • In your controllers, use the jamesi_notification.notifier service (an instance of the Notifier class) to send out notifications, using the notify method.

统计信息

  • 总下载量: 36
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固