/** * @param $webHook * @param $requestData */ private function forwardNotification(WebHook $webHook, $requestData) { $this->socketAdminClient = $this->get('socket_admin_client'); $this->socketAdminClient->start(function () use($webHook, $requestData) { $this->socketAdminClient->executeSendRequest($webHook, $requestData, function () { $this->socketAdminClient->stop(); }, function () { $this->socketAdminClient->stop(); throw new NotFoundHttpException(); }); }); }
/** * Deletes a WebHook entity. * * @Route("/{id}", name="webhook_delete") * @Method("DELETE") * * @param Request $request * @param WebHook $webHook * * @return RedirectResponse */ public function deleteAction(Request $request, WebHook $webHook) { $form = $this->createDeleteForm($webHook); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); // Delete channel in Socket $this->socketAdminClient = $this->get('socket_admin_client'); $this->socketAdminClient->start(function () use($webHook, $em) { $this->socketAdminClient->executeRemoveWebHook($webHook, function () use($webHook, $em) { $em->remove($webHook); $em->flush(); $this->socketAdminClient->stop(); }, function ($msg) { $this->socketAdminClient->stop(); throw new Exception('Socket error: ' . json_encode($msg)); }); }); } return $this->redirectToRoute('webhook_index'); }