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