/** * {@inheritdoc} */ public function getConfiguration(Notification $notification) { if ($notification->hasNotifierAlias()) { try { return $this->getDataBaseConfiguration($notification->getNotifierAlias(), $notification->getType()); } catch (UndefinedNotifierConfigurationException $e) { return $this->getFileConfiguration($notification->getNotifierAlias()); } } if (null !== $notification->getFrom()) { $from = json_decode($notification->getFrom(), true); if (null === $from) { throw new ConfigurationParseErrorException($notification->getFrom()); } elseif (count($from) > 0) { return $from; } } return $this->getFileConfiguration(); }
/** * Notify * * @param Notification $notification */ public function notify(Notification $notification) { $notifier = $this->getNotifier($notification->getType()); try { $notifier->sendNotification($notification); $notification->setStatus(Notification::STATUS_DONE); } catch (\Exception $e) { $notification->setStatus(Notification::STATUS_ERROR); $notification->addLog($e->getMessage()); } $this->getObjectManager()->persist($notification); $this->getObjectManager()->flush(); }