refactor(form-builder): consolidate subject-type allow-list into purpose registry
Q6 of ARCH-CONSOLIDATION-ADDENDUM-2026-04-24: the allowed `form_submissions.subject_type` values are now derived from `PurposeRegistry::allSubjectTypes()` instead of the parallel `config/form_subjects.php` file. - CreateFormSubmissionRequest validates `subject_type` against the registry via constructor-injected PurposeRegistry. - FormSubmissionController and FormValueService resolve the subject FQCN through `Relation::getMorphedModel()` — the morph-map is the single source of truth for alias → model mapping. - `config/form_subjects.php` is deleted. `MorphMapAlignmentTest` keeps the registry and morph-map aligned going forward. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,11 +4,18 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Api\V1\FormBuilder;
|
||||
|
||||
use App\FormBuilder\Purposes\PurposeRegistry;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
final class CreateFormSubmissionRequest extends FormRequest
|
||||
{
|
||||
public function __construct(
|
||||
private readonly PurposeRegistry $purposeRegistry,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
@@ -19,10 +26,8 @@ final class CreateFormSubmissionRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$allowedSubjects = array_keys((array) config('form_subjects', []));
|
||||
|
||||
return [
|
||||
'subject_type' => ['nullable', Rule::in($allowedSubjects)],
|
||||
'subject_type' => ['nullable', Rule::in($this->purposeRegistry->allSubjectTypes())],
|
||||
'subject_id' => ['nullable', 'string', 'max:30', 'required_with:subject_type'],
|
||||
'idempotency_key' => ['nullable', 'string', 'max:30'],
|
||||
'is_test' => ['boolean'],
|
||||
|
||||
Reference in New Issue
Block a user