Coder Social home page Coder Social logo

helpfulrobot / webtorque-silverstripe-notifications Goto Github PK

View Code? Open in Web Editor NEW

This project forked from webtorque/silverstripe-notifications

0.0 2.0 0.0 60 KB

A SilverStripe module for handling notifications.

Home Page: http://webtorque.co.nz

License: MIT License

ApacheConf 0.34% PHP 99.15% Scheme 0.51%

webtorque-silverstripe-notifications's Introduction

silverstripe-notifications

A SilverStripe module for handling notifications to user. This can be use to send notifications via various mediums to a Member.

Various notification are handled via a NotificationProvider. e.g.: NotificationEmailProvider will send email notifications while NotificationDataObjectProvider will store notifications in a DataObject for display one the website frontend.

Build Status

Requirements

  • PHP 5.5 or greater (tested with up to PHP 7.1)
  • silverstripe/framework:^3.2
  • silverstripe/cms:^3.2

Optional

  • giggsey/libphonenumber-for-php:^8.0

Installing libphonenumber-for-php provides better mobile phone number validation.

Installation

composer require webtorque/silverstripe-notifications:^0.0

Configuration

Create a YAML config file to configure the NotificationService. You need to speciify a notification parser and a list of notification providers.

NotificationService:
  constructor:
    0: '%$NotificationParser'
    1:
      - "%$NotificationEmailProvider"
      - "%$NotificationDataObjectProvider"

The built-in NotificationParser will read notification format information from a NotificationType data objects. Notification types can be edited in the CMS. The expectation is that notification types will be predefined in your YML config. Creation or deletion of notification type are disallowed for all users.

NotificationType:
  default_records:
    - SystemName: 'RegistrationApproval'
      Name: 'Registration Approval'

    - SystemName: 'RegistrationApproved'
      Name: 'Registration Approved'

    - SystemName: 'NewPatientRequest'
      Name: 'New Patient Request'

    - SystemName: 'PatientRequestApproved'
      Name: 'Patient Request Approved'

    - SystemName: 'PatientRequestDeclined'
      Name: 'Patient Request Declined'

Usage

$service = Injector::inst()->get('NotificationService');
$deliveries = $service->send(
    'RegistrationApproval',                         # Notification type system name.
    ['extra' => 'Data to inject in the message'],   # Abritary data to inject in the NotificationParser.
    Member::currentUser(),                          # User who should receive the notification.
    '/notification/call-to-action-url'              # Optional Call-to-Action URL.
);

# List of NotificationFailureException for providers who failed to deliver the notification.
$deliveries->getFailures();   

# List of response from providers delivered their notification as expected.
$deliveries->getDeliveries();

webtorque-silverstripe-notifications's People

Contributors

maxime-rainville avatar

Watchers

James Cloos avatar helpfulrobot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.