clientManager = $clientManager; } /** * Writes to a body. */ public function write(Response $response, Params $params): void { $body = $this->render($params->getController(), $params->getAction(), $params->getData()); $this->clientManager->writeHeaders($response); $response->writeBody($body); } /** * @deprecated Use`write`. * @param ?array $data */ public function render(string $controller, string $action, ?array $data = null): string { $encodedData = Json::encode($data); $script = " require('{$controller}', Controller => { let controller = new Controller(app.baseController.params, app.getControllerInjection()); controller.masterView = app.masterView; controller.doAction('{$action}', {$encodedData}); }); "; return $this->clientManager->render($script); } }