Adds PurposeGuardProvider as a parallel interface to PurposeDefinition (value object stays untouched). Seven concrete providers, one per v1.0 purpose, each declaring its publish-guard list. Registry resolves and caches providers via guards_class config key. Universal guards (MaxOneIdentityKeyPerTargetEntity, AppendStrategyRequiresCollectionTarget, NoAmbiguousTrustLevels, IdentityKeyBindingsOnlyInFirstSection) wire into every purpose. The section guard is a cheap no-op when section_level_submit=false. ArtistAdvanceGuards omits RequiresIdentityKeyBinding because the artist subject is resolved via portal token, not form data. Same reasoning for supplier_intake (production_request) and the auth-based purposes. Includes a cross-cutting BindingTypeRegistryConsistencyTest that verifies tasks 5/7/8 do not contradict each other (registry ↔ guards ↔ purpose required_bindings). Refs: RFC-WS-6.md §3 (Q9, Q13) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
93 lines
3.4 KiB
PHP
93 lines
3.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Enums\FormBuilder\FormSubmissionMode;
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Form Builder — Purpose registry (v1.0)
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Declarative set of purposes served by the universal form builder. v1.0
|
|
| ships seven purposes. Adding a new purpose requires a code change (this
|
|
| file) plus, typically, a new listener — per ARCH-CONSOLIDATION §3
|
|
| besluit 4. Purposes are not user-defined.
|
|
|
|
|
| Each purpose declares:
|
|
| - label (NL): organizer-facing label
|
|
| - subject_type: morph alias used for form_submissions.subject_type
|
|
| - default_submission_mode: FormSubmissionMode enum case
|
|
| - allows_public_access: schema-level public submission without token
|
|
| - required_bindings: list of "{entity}.{attribute}" binding paths
|
|
| that must be present on a schema before publish
|
|
|
|
|
*/
|
|
|
|
return [
|
|
|
|
'event_registration' => [
|
|
'label' => 'Aanmelding vrijwilligers/crew',
|
|
'subject_type' => 'person',
|
|
'default_submission_mode' => FormSubmissionMode::SINGLE,
|
|
'allows_public_access' => true,
|
|
'required_bindings' => ['person.email', 'person.first_name', 'person.last_name'],
|
|
'guards_class' => \App\FormBuilder\Purposes\Guards\EventRegistrationGuards::class,
|
|
],
|
|
|
|
'artist_advance' => [
|
|
'label' => 'Artiest advance',
|
|
'subject_type' => 'artist',
|
|
'default_submission_mode' => FormSubmissionMode::DRAFT_SINGLE,
|
|
'allows_public_access' => false,
|
|
'required_bindings' => [],
|
|
'guards_class' => \App\FormBuilder\Purposes\Guards\ArtistAdvanceGuards::class,
|
|
],
|
|
|
|
'supplier_intake' => [
|
|
'label' => 'Leverancier intake',
|
|
'subject_type' => 'company',
|
|
'default_submission_mode' => FormSubmissionMode::SINGLE,
|
|
'allows_public_access' => false,
|
|
'required_bindings' => ['company.name'],
|
|
'guards_class' => \App\FormBuilder\Purposes\Guards\SupplierIntakeGuards::class,
|
|
],
|
|
|
|
'post_event_evaluation' => [
|
|
'label' => 'Evaluatie na afloop',
|
|
'subject_type' => 'person',
|
|
'default_submission_mode' => FormSubmissionMode::SINGLE,
|
|
'allows_public_access' => false,
|
|
'required_bindings' => [],
|
|
'guards_class' => \App\FormBuilder\Purposes\Guards\PostEventEvaluationGuards::class,
|
|
],
|
|
|
|
'incident_report' => [
|
|
'label' => 'Incident-melding',
|
|
'subject_type' => 'person',
|
|
'default_submission_mode' => FormSubmissionMode::MULTIPLE,
|
|
'allows_public_access' => false,
|
|
'required_bindings' => [],
|
|
'guards_class' => \App\FormBuilder\Purposes\Guards\IncidentReportGuards::class,
|
|
],
|
|
|
|
'signature_contract' => [
|
|
'label' => 'Contract-ondertekening',
|
|
'subject_type' => 'user',
|
|
'default_submission_mode' => FormSubmissionMode::SINGLE,
|
|
'allows_public_access' => false,
|
|
'required_bindings' => [],
|
|
'guards_class' => \App\FormBuilder\Purposes\Guards\SignatureContractGuards::class,
|
|
],
|
|
|
|
'user_profile' => [
|
|
'label' => 'Profiel-update',
|
|
'subject_type' => 'user',
|
|
'default_submission_mode' => FormSubmissionMode::SINGLE,
|
|
'allows_public_access' => false,
|
|
'required_bindings' => [],
|
|
'guards_class' => \App\FormBuilder\Purposes\Guards\UserProfileGuards::class,
|
|
],
|
|
|
|
];
|