model = $model; $this->relation = $relation; } public function __invoke(ServerRequest $request): void { global $cfg; $templateId = (int) $request->getParsedBodyParam('templateId'); /** @var string $templateData */ $templateData = $request->getParsedBodyParam('templateData', ''); $cfgRelation = $this->relation->getRelationsParam(); if (! $cfgRelation['exporttemplateswork']) { return; } $template = ExportTemplate::fromArray([ 'id' => $templateId, 'username' => $cfg['Server']['user'], 'data' => $templateData, ]); $result = $this->model->update($cfgRelation['db'], $cfgRelation['export_templates'], $template); if (is_string($result)) { $this->response->setRequestStatus(false); $this->response->addJSON('message', $result); return; } $this->response->setRequestStatus(true); } }