toCommand(); $command->userId = $this->getUser()->getId(); $response = $handler->handle($command); $this->broadcaster->alert( title: 'Success', message: "New monitor added for {$input->title}", ); return $this->json([ 'status' => 200, 'message' => $response ]); } #[Route('/api/monitor/{monitorId}', name: 'api_monitor_delete', methods: ['DELETE'])] public function deleteMonitor( DeleteMonitorInput $input, DeleteMonitorHandler $handler, HubInterface $hub, ) { $response = $handler->handle($input->toCommand()); $hub->publish(new Update( 'alerts', $this->renderer->render('broadcast/Alert.stream.html.twig', [ 'alert_id' => uniqid(), 'title' => 'Success', 'message' => "New monitor added for {$response->monitor->getTitle()}", ]) )); return $this->json([ 'status' => 200, 'message' => $response ]); } }