private function sendNotificationEmail(NotificationInterface $notification) { if (null === $notification->getMailTemplate()) { $notification->setMailTemplate($this->notificationHandler->getEmailHtml($notification)); } $this->mailer->sendEmailBasedOnNotification($notification->getId(), $notification->getCategory()->getMailSenderAddress(), $notification->getPerson()->getEmail(), $notification->getTitle(), $notification->getMailTemplate()); }
public function send(NotificationInterface $notification) { if ($notification->canBeSent()) { $handler = $this->getNotificationHandler(); $serializer = $this->container->get('jms_serializer'); $context = SerializationContext::create()->setGroups('form'); $array = json_decode($serializer->serialize($notification, 'json', $context), true); $handler->patch($notification, array()); } else { $translator = $this->container->get('translator'); throw new AccessDeniedException($translator->trans("This notification cannot be sent to this user. Check the notification level and whether the user has authorized the application.")); } }
private function sendCallback(NotificationInterface $notification, ObjectManager $om) { if ($notification->getCallbackUrl()) { $secret = $notification->getCategory()->getClient()->getSecret(); $base['data'] = json_encode(array('id' => $notification->getId(), 'person_id' => $notification->getPerson()->getId(), 'read_date' => $notification->getReadDate()->getTimestamp())); $base['signature'] = hash_hmac('sha256', $base['data'], $secret); $dataPost = http_build_query($base); curl_setopt($this->ch, CURLOPT_URL, $notification->getCallbackUrl()); curl_setopt($this->ch, CURLOPT_POST, 1); curl_setopt($this->ch, CURLOPT_POSTFIELDS, $dataPost); $curlResponse = curl_exec($this->ch); $code = curl_getinfo($this->ch, CURLINFO_HTTP_CODE); if ($code != '200') { $this->registerFailedCallback($notification, $om, $this->ch, $curlResponse); } } }