PHP code example of mkebza / notificator-bundle

1. Go to this page and download the library: Download mkebza/notificator-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mkebza / notificator-bundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new MKebza\Notificator\MKebzaNotificatorBundle(),
        );

        // ...
    }

    // ...
}

namespace App\Notification;

class TestNotification implements NotificationInterface
{
    public function getChannels(NotifiableInterface $target): array
    {
        // Returns which channels this notification implements
        return [
            'email'
        ];
    }

    // Renders notification for handler
    public function email(Notification $notification, array $options): Notification
    {
        $message = (new \Swift_Message())
            ->setSubject('Test subject')
            ->setBody('Test');

        return $notification->setContent($message);
    }
}

$notificator->send($user, TestNotification::class, ['data' => 'will_be_passed']);
$notificator->send([$user1, $user2], TestNotification::class, ['data' => 'will_be_passed']);