addHandler() public method

Adds an handler to this manager.
public addHandler ( Namshi\Notificator\Notification\Handler\HandlerInterface $handler )
$handler Namshi\Notificator\Notification\Handler\HandlerInterface
Exemplo n.º 1
0
 function notify($event)
 {
     $result = $event->getResult();
     $failed = $result->failureCount() or $result->errorCount();
     $manager = new Manager();
     $manager->addHandler(new NotifySendHandler());
     $notification = new NotifySendNotification("Codeception Tests " . ($failed ? "FAILED" : "PASSED"));
     $manager->trigger($notification);
 }
Exemplo n.º 2
0
 function notify($event)
 {
     $result = $event->getResult();
     $failed = $result->failureCount() or $result->errorCount();
     // print_r($this->config);
     if (!isset($this->config['email'])) {
         throw new \Codeception\Exception\Extension(__CLASS__, 'email option is required');
     }
     $email = $this->config['email'];
     $status = $failed ? 'FAILED' : 'PASSED';
     $print = $event->getPrinter()->printResult($result);
     // create the manager and assign the handler to it
     $manager = new Manager();
     $manager->addHandler(new SimpleEmailHandler());
     $notification = new SimpleEmailNotification($email, "Codeception tests {$status}", $print);
     $manager->trigger($notification);
 }
Exemplo n.º 3
0
<?php

require __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR . "autoload.php";
// import namespaces
use Namshi\Notificator\Manager;
use Namshi\Notificator\Notification\Handler\SwiftMailer as SwiftMailerHandler;
use Namshi\Notificator\Notification\Email\SwiftMailer\SwiftMailerNotification;
// create transport
$transport = Swift_SmtpTransport::newInstance('EMAIL_PROVIDER_HOST', 'EMAIL_PROVIDER_PORT');
// set the username and password
$transport->setUsername('USERNAME');
$transport->setPassword('PASSWORD');
// create mailer
$mailer = Swift_Mailer::newInstance($transport);
// create message
$message = new Swift_Message();
$message->setTo('*****@*****.**');
$message->setFrom('*****@*****.**');
$message->setSubject('TEST EMAIL');
$message->setBody('Hello!');
$notification = new SwiftMailerNotification('test_template', array('*****@*****.**'), array());
$notification->setMessage($message);
// create the handler
$handler = new SwiftMailerHandler($mailer);
// create a manager
$manager = new Manager();
$manager->addHandler($handler);
// trigger the notification
$manager->trigger($notification);