public function send(string $recipientID, Notification $notification): void
    {
        $app = App::get();

        if ($notification->id === null) {
            $notification->id = 'n' . uniqid() . 'x' . base_convert(rand(0, 999999999), 10, 16);
        }
        if ($notification->dateCreated === null) {
            $notification->dateCreated = time();
        }

        if ($this->hasEventListeners('beforeSendNotification')) {
            $eventDetails = new \IvoPetkov\BearFrameworkAddons\Notifications\BeforeSendNotificationEventDetails($recipientID, $notification);
            $this->dispatchEvent('beforeSendNotification', $eventDetails);
            if ($eventDetails->preventDefault) {
                return;
            }
        }

        if (strlen($notification->type) > 0) {
            $otherNotifications = $this->getList($recipientID);
            foreach ($otherNotifications as $otherNotification) {
                if ((string) $notification->type === (string) $otherNotification->type) {
                    $this->delete($recipientID, $otherNotification->id);
                }
            }
        }

        $this->set($recipientID, $notification);

        if ($this->hasEventListeners('sendNotification')) {
            $eventDetails = new \IvoPetkov\BearFrameworkAddons\Notifications\SendNotificationEventDetails($recipientID, $notification);
            $this->dispatchEvent('sendNotification', $eventDetails);
        }
    }
public function send(string $recipientID, Notification $notification): void
    {
        $app = App::get();

        if ($notification->id === null) {
            $notification->id = 'n' . uniqid() . 'x' . base_convert(rand(0, 999999999), 10, 16);
        }
        if ($notification->dateCreated === null) {
            $notification->dateCreated = time();
        }

        if ($this->hasEventListeners('beforeSendNotification')) {
            $eventDetails = new \IvoPetkov\BearFrameworkAddons\Notifications\BeforeSendNotificationEventDetails($recipientID, $notification);
            $this->dispatchEvent('beforeSendNotification', $eventDetails);
            if ($eventDetails->preventDefault) {
                return;
            }
        }

        if (strlen($notification->type) > 0) {
            $otherNotifications = $this->getList($recipientID);
            foreach ($otherNotifications as $otherNotification) {
                if ((string) $notification->type === (string) $otherNotification->type) {
                    $this->delete($recipientID, $otherNotification->id);
                }
            }
        }

        $this->set($recipientID, $notification);

        if ($this->hasEventListeners('sendNotification')) {
            $eventDetails = new \IvoPetkov\BearFrameworkAddons\Notifications\SendNotificationEventDetails($recipientID, $notification);
            $this->dispatchEvent('sendNotification', $eventDetails);
        }
    }
public function send ( string $ recipientID , Notification $ notification ) : void { $ app = App :: get ( ) ; if ( $ notification -> id === null ) { $ notification -> id = 'n' . uniqid ( ) . 'x' . base_convert ( rand ( 0 , 999999999 ) , 10 , 16 ) ; } if ( $ notification -> dateCreated === null ) { $ notification -> dateCreated = time ( ) ; } if ( $ this -> hasEventListeners ( 'beforeSendNotification' ) ) { $ eventDetails = new \ IvoPetkov \ BearFrameworkAddons \ Notifications \ BeforeSendNotificationEventDetails ( $ recipientID , $ notification ) ; $ this -> dispatchEvent ( 'beforeSendNotification' , $ eventDetails ) ; if ( $ eventDetails -> preventDefault ) { return ; } } if ( strlen ( $ notification -> type ) > 0 ) { $ otherNotifications = $ this -> getList ( $ recipientID ) ; foreach ( $ otherNotifications as $ otherNotification ) { if ( ( string ) $ notification -> type === ( string ) $ otherNotification -> type ) { $ this -> delete ( $ recipientID , $ otherNotification -> id ) ; } } } $ this -> set ( $ recipientID , $ notification ) ; if ( $ this -> hasEventListeners ( 'sendNotification' ) ) { $ eventDetails = new \ IvoPetkov \ BearFrameworkAddons \ Notifications \ SendNotificationEventDetails ( $ recipientID , $ notification ) ; $ this -> dispatchEvent ( 'sendNotification' , $ eventDetails ) ; } }
Sends a notification.

@param string $recipientID The recipient ID.
@param \BearFramework\Notifications\Notification $notification The notification to send.
@return void No value is returned.
@throws \Exception
Sends a notification .