clientManager = $clientManager; $this->service = $service; } public function run(Request $request, Response $response): void { $id = $request->getQueryParam('id'); if (!$id) { throw new BadRequest(); } $data = $this->service->confirmOptIn($id); if ($data->status === 'success') { $action = 'optInConfirmationSuccess'; } else if ($data->status === 'expired') { $action = 'optInConfirmationExpired'; } else { throw new Error(); } $runScript = " Espo.require('controllers/lead-capture-opt-in-confirmation', function (Controller) { var controller = new Controller(app.baseController.params, app.getControllerInjection()); controller.masterView = app.masterView; controller.doAction('".$action."', ".json_encode($data)."); }); "; $this->clientManager->display($runScript); } }