public function replay(Request $baseRequest, Notification $notification)
 {
     $webHook = $notification->getWebHook();
     $endpoint = $webHook->getEndpoint();
     $content = json_decode($notification->getContent(), true);
     $query = array_merge(['username' => $webHook->getUser()->getUsername(), 'endpoint' => $endpoint], $content['query']);
     $url = $this->router->generate('notifications', $query);
     $request = Request::create($url, $content['method'], [], [], [], $baseRequest->server->all(), $content['body']);
     $request->headers->replace($content['headers']);
     $response = $this->kernel->handle($request, HttpKernelInterface::SUB_REQUEST);
     return $response;
 }
Ejemplo n.º 2
0
 /**
  * Sends a notification through socket.io
  *
  * @param  Notification $notification
  * @param  string       $actionUrl
  * @return void
  */
 private function sendNotification($notification, $actionUrl = null)
 {
     $data = array('id' => (string) $notification->getId(), 'title' => $notification->getTitle(), 'content' => $notification->getContent(), 'actionCaption' => $notification->getActionCaption(), 'actionUrl' => $actionUrl);
     $socketClient = $this->get('elephantio_client.ainotifier');
     $socketClient->send('new', ['notification' => json_encode($data)]);
 }