diff --git a/src/Controller/MachineStructureController.php b/src/Controller/MachineStructureController.php index adc4b4f..10f753d 100644 --- a/src/Controller/MachineStructureController.php +++ b/src/Controller/MachineStructureController.php @@ -191,6 +191,7 @@ class MachineStructureController extends AbstractController $newCf->setDefaultValue($cf->getDefaultValue()); $newCf->setOptions($cf->getOptions()); $newCf->setOrderIndex($cf->getOrderIndex()); + $newCf->setMachineContextOnly($cf->isMachineContextOnly()); $newCf->setMachine($target); $this->entityManager->persist($newCf); diff --git a/src/Service/SkeletonStructureService.php b/src/Service/SkeletonStructureService.php index c58d177..2f1cd9a 100644 --- a/src/Service/SkeletonStructureService.php +++ b/src/Service/SkeletonStructureService.php @@ -233,6 +233,7 @@ class SkeletonStructureService $existingField->setOptions($normalized['options']); $existingField->setDefaultValue($normalized['defaultValue']); $existingField->setOrderIndex($normalized['orderIndex']); + $existingField->setMachineContextOnly($normalized['machineContextOnly']); $processedIds[$existingField->getId()] = true; } else { // Create new field @@ -243,6 +244,7 @@ class SkeletonStructureService $cf->setOptions($normalized['options']); $cf->setDefaultValue($normalized['defaultValue']); $cf->setOrderIndex($normalized['orderIndex']); + $cf->setMachineContextOnly($normalized['machineContextOnly']); match ($category) { ModelCategory::COMPONENT => $cf->setTypeComposant($modelType), @@ -265,7 +267,7 @@ class SkeletonStructureService /** * Normalize frontend custom field data to a common shape. * - * @return array{name: string, type: string, required: bool, options: ?array, defaultValue: ?string, orderIndex: int} + * @return array{name: string, type: string, required: bool, options: ?array, defaultValue: ?string, orderIndex: int, machineContextOnly: bool} */ private function normalizeCustomFieldData(array $fieldData, int $index): array { @@ -274,23 +276,25 @@ class SkeletonStructureService $value = $fieldData['value']; return [ - 'name' => $fieldData['key'], - 'type' => $value['type'] ?? 'text', - 'required' => (bool) ($value['required'] ?? false), - 'options' => $value['options'] ?? null, - 'defaultValue' => $value['defaultValue'] ?? null, - 'orderIndex' => $index, + 'name' => $fieldData['key'], + 'type' => $value['type'] ?? 'text', + 'required' => (bool) ($value['required'] ?? false), + 'options' => $value['options'] ?? null, + 'defaultValue' => $value['defaultValue'] ?? null, + 'orderIndex' => $index, + 'machineContextOnly' => (bool) ($value['machineContextOnly'] ?? false), ]; } // PIECE/PRODUCT format: {name, type, required, options?, orderIndex?, defaultValue?} return [ - 'name' => $fieldData['name'] ?? '', - 'type' => $fieldData['type'] ?? 'text', - 'required' => (bool) ($fieldData['required'] ?? false), - 'options' => $fieldData['options'] ?? null, - 'defaultValue' => $fieldData['defaultValue'] ?? null, - 'orderIndex' => $fieldData['orderIndex'] ?? $index, + 'name' => $fieldData['name'] ?? '', + 'type' => $fieldData['type'] ?? 'text', + 'required' => (bool) ($fieldData['required'] ?? false), + 'options' => $fieldData['options'] ?? null, + 'defaultValue' => $fieldData['defaultValue'] ?? null, + 'orderIndex' => $fieldData['orderIndex'] ?? $index, + 'machineContextOnly' => (bool) ($fieldData['machineContextOnly'] ?? false), ]; } }