refactor(form-builder): drop legacy snapshot 'binding' (singular) key (WS-6)
Session 2 wrote both 'binding' (singular) and 'bindings' (plural) in form_submissions.schema_snapshot for backward compatibility. With no production data yet and dev seeders re-running every cycle, dual- key state has no upside. Snapshots now write 'bindings' only; all readers updated to match. FormFieldBindingService::snapshotShapesFor() simplified to return only ['bindings' => $all]. Pre-existing SchemaSnapshotEmbedsBindingFromRelationalTableTest updated to assert the applicator shape (with id, merge_strategy, trust_level, is_identity_key) on bindings[0]; new SnapshotOnlyContainsBindingsKeyTest enforces the no-legacy-key contract going forward. FormBuilderDevSeeder template snapshot embeds 'bindings' => [] for form-owned fields (Pattern B) instead of 'binding' => null. Other 'binding' string occurrences in the codebase (FormFieldResource, FormFieldService, request validation rules, BindingConflictResolver internal helper key) are unrelated to snapshot dual-state and remain untouched. Refs: WS-6 session 2 deviation #9 cleanup Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -192,26 +192,22 @@ final class FormFieldBindingService
|
||||
}
|
||||
|
||||
/**
|
||||
* Build snapshot fragments for both the legacy `binding` (singular)
|
||||
* key and the new WS-6 `bindings` (plural) key in one pass over the
|
||||
* collection. Single helper so the FormSubmissionService snapshot
|
||||
* loop accesses `$field->bindings` only once.
|
||||
* Build the snapshot fragment for the WS-6 `bindings` (plural) key.
|
||||
* Session 2.5 dropped the legacy `binding` (singular) — see RFC v1.1
|
||||
* + WS-6 session 2 deviation #9. With no production data and dev
|
||||
* seeders re-running every cycle, dual-key state had no upside.
|
||||
*
|
||||
* @param iterable<FormFieldBinding> $bindings
|
||||
* @return array{binding: array<string, mixed>|null, bindings: list<array<string, mixed>>}
|
||||
* @return array{bindings: list<array<string, mixed>>}
|
||||
*/
|
||||
public function snapshotShapesFor(iterable $bindings): array
|
||||
{
|
||||
$first = null;
|
||||
$all = [];
|
||||
foreach ($bindings as $binding) {
|
||||
if ($first === null) {
|
||||
$first = $this->toJsonShape($binding);
|
||||
}
|
||||
$all[] = $this->toApplicatorShape($binding);
|
||||
}
|
||||
|
||||
return ['binding' => $first, 'bindings' => $all];
|
||||
return ['bindings' => $all];
|
||||
}
|
||||
|
||||
private function ownerTypeFor(FormField|FormFieldLibrary $owner): string
|
||||
|
||||
Reference in New Issue
Block a user