Files
crewli/api/app/FormBuilder/Purposes/PurposeDefinition.php
bert.hausmans e93207765b feat(form-builder): introduce purpose registry and definition value object
Lands the v1.0 purpose registry (WS-2 of the consolidation sprint) as a
first-class concept: a `PurposeDefinition` value object, a
`PurposeRegistry` service keyed by slug, and a declarative
`config/form_builder/purposes.php` registry with exactly the seven
purposes from ARCH-CONSOLIDATION §6.4.

Also rebuilds the morph-map in `AppServiceProvider::boot` into three
labelled blocks: (1) domain subject types derived from
`PurposeRegistry::allSubjectTypes()`, (2) non-purpose domain types
hardcoded with comments (form_schemas owner_types, activity-log
subjects), (3) framework types (spatie/activitylog; Sanctum stays
absent per addendum Q4).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 14:35:18 +02:00

26 lines
857 B
PHP

<?php
declare(strict_types=1);
namespace App\FormBuilder\Purposes;
use App\Enums\FormBuilder\FormSubmissionMode;
final readonly class PurposeDefinition
{
/**
* @param list<string> $requiredBindings Binding paths in `{entity}.{attribute}` form
* (Pattern A notation used in `form_fields.binding` JSON).
* Consumed by the pre-publish check (FormSchemaService::publish)
* and, after WS-5/WS-6, by `form_field_bindings`.
*/
public function __construct(
public string $slug,
public string $label,
public string $subjectType,
public FormSubmissionMode $defaultSubmissionMode,
public bool $allowsPublicAccess,
public array $requiredBindings,
) {}
}