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, ) { $response = $handler->handle($input->toCommand()); return $this->json([ 'status' => 200, 'message' => $response ]); } #[Route('/api/monitor/dispatch', name: 'api_monitor_dispatch', methods: ['GET'])] public function dispatch(MonitorDispatcher $dispatcher, Broadcaster $broadcaster): Response { $dispatcher(); $broadcaster->alert('Success', 'The monitor job has been dispatched.'); return $this->json([ 'status' => 200, 'message' => 'Manually dispatched MonitorDispatcher' ]); } }