public trigger ( Namshi\Notificator\NotificationInterface $notification ) | ||
$notification | Namshi\Notificator\NotificationInterface |
public function trigger(NotificationInterface $notification)
{
foreach ($this->getHandlers() as $handler) {
if ($handler->shouldHandle($notification)) {
if ($logger = $this->getLogger()) {
$message = sprintf('notification handler "%s" processed message', get_class($handler));
$logger->info($message, array('Notification' => serialize($notification)));
}
if (false === $handler->handle($notification)) {
return true;
}
}
}
return true;
}
/** * {@inheritdoc} */ public function handle(NotificationInterface $notification) { /** @var ChainedNotificationInterface $notification */ foreach ($notification->getNotifications() as $notify) { $this->manager->trigger($notify); } }