public function notify($identifier, $context, $data = [], $channel = null)
    {
        // okay, lets find any notification set up with this identifier
        if ($notifications = SystemNotification::get()->filter('Identifier', $identifier)) {
            foreach ($notifications as $notification) {
                if ($notification->NotifyOnClass) {
                    $subclasses = ClassInfo::subclassesFor($notification->NotifyOnClass);
                    if (!isset($subclasses[strtolower(get_class($context))])) {
                        continue;
                    }
                }

                // figure out the channels to send the notification on
                $channels = $channel ? [$channel] : [];
                if ($notification->Channels) {
                    $channels = json_decode($notification->Channels);
                }

                $this->sendNotification($notification, $context, $data, $channels);
            }
        }
    }
public function notify($identifier, $context, $data = [], $channel = null)
    {
        // okay, lets find any notification set up with this identifier
        if ($notifications = SystemNotification::get()->filter('Identifier', $identifier)) {
            foreach ($notifications as $notification) {
                if ($notification->NotifyOnClass) {
                    $subclasses = ClassInfo::subclassesFor($notification->NotifyOnClass);
                    if (!isset($subclasses[strtolower(get_class($context))])) {
                        continue;
                    }
                }

                // figure out the channels to send the notification on
                $channels = $channel ? [$channel] : [];
                if ($notification->Channels) {
                    $channels = json_decode($notification->Channels);
                }

                $this->sendNotification($notification, $context, $data, $channels);
            }
        }
    }
public function notify ( $ identifier , $ context , $ data = [ ] , $ channel = null ) { // okay, lets find any notification set up with this identifier if ( $ notifications = SystemNotification :: get ( ) -> filter ( 'Identifier' , $ identifier ) ) { foreach ( $ notifications as $ notification ) { if ( $ notification -> NotifyOnClass ) { $ subclasses = ClassInfo :: subclassesFor ( $ notification -> NotifyOnClass ) ; if ( ! isset ( $ subclasses [ strtolower ( get_class ( $ context ) ) ] ) ) { continue ; } } // figure out the channels to send the notification on $ channels = $ channel ? [ $ channel ] : [ ] ; if ( $ notification -> Channels ) { $ channels = json_decode ( $ notification -> Channels ) ; } $ this -> sendNotification ( $ notification , $ context , $ data , $ channels ) ; } } }
Trigger a notification event
@param string      $identifier The Identifier of the notification event
@param DataObject  $context    The context (if relevant) of the object to notify on
@param array       $data       Extra data to be sent along with the notification
@param string|null $channel
Trigger a notification event