/**
  * Call all transporter for the action of the NotificationInterface
  *
  * @param NotificationInterface $notification
  */
 public function callTransporter(NotificationInterface $notification)
 {
     $configuration = $this->getConfiguration($notification->getAction());
     if (null === $configuration) {
         return null;
     }
     if (isset($configuration['transporters'])) {
         $notificationComponents = $this->notificationManager->findAllNotificationComponent($notification);
         $notificationRecipients = $this->notificationManager->findAllRecipientsByNotification($notification);
         /** @var RecipientInterface $notificationRecipient */
         foreach ($notificationRecipients as $notificationRecipient) {
             $recipientComponent = $notificationRecipient->getComponent();
             $settings = $this->componentSettingManager->findOrCreateComponentSetting($recipientComponent);
             $actionsEnabled = $settings->getActionsEnabled();
             if (array_key_exists($notification->getAction(), $actionsEnabled)) {
                 foreach ($configuration['transporters'] as $name => $params) {
                     if (in_array($name, $actionsEnabled[$notification->getAction()])) {
                         $transporterId = $params['id'];
                         if (null !== ($transporter = $this->transporter->getTransporter($transporterId))) {
                             $transporter->setConfiguration(isset($params['config']) ? $params['config'] : array());
                             $transporter->send($notification, $notificationComponents, $notificationRecipient);
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * @param ComponentInterface $subject
  * @param $action
  * @param array $components
  * @return \DCS\NotificationBundle\Model\NotificationInterface
  * @throws \Exception
  */
 public function notify(ComponentInterface $subject, $action, array $components = null, $forceNotify = false)
 {
     $notification = $this->notificationManager->createNotification($action);
     $notification->setSubject($subject);
     $this->notificationManager->saveNotification($notification);
     if (null !== $components && count($components)) {
         foreach ($components as $type => $component) {
             if (!$component instanceof ComponentInterface) {
                 throw new \Exception('The components %s is not a ComponentInterface. Use the method "findOrCreateComponent"', $type);
             }
             $notificationComponent = $this->notificationManager->createNotificationComponent();
             $notificationComponent->setNotification($notification);
             $notificationComponent->setComponent($component);
             $notificationComponent->setType($type);
             $this->notificationManager->saveNotificationComponent($notificationComponent);
         }
     }
     if ($forceNotify || $this->mode == 'runtime') {
         $this->notifierService->process($notification);
     }
     return $notification;
 }