getRouteParam('id'); if (!$id) { throw new BadRequest(); } $data = $request->getParsedBody(); $field = $data->field ?? null; $parentType = $data->parentType ?? null; $relatedType = $data->relatedType ?? null; if (!$field) { throw new BadRequest("No `field`."); } try { $fieldData = new FieldData($field, $parentType, $relatedType); } catch (Error $e) { throw new BadRequest($e->getMessage()); } $attachment = $this->service->copy($id, $fieldData); return ResponseComposer::json($attachment->getValueMap()); } }