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:
@@ -14,6 +14,7 @@ use App\Models\FormBuilder\FormSubmission;
|
||||
use App\Models\Organisation;
|
||||
use App\Services\FormBuilder\FormSubmissionService;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
@@ -103,9 +104,8 @@ final class FormSubmissionController extends Controller
|
||||
if ($type === '' || $id === '') {
|
||||
return null;
|
||||
}
|
||||
$map = (array) config('form_subjects');
|
||||
$class = $map[$type]['model'] ?? null;
|
||||
if ($class === null) {
|
||||
$class = Relation::getMorphedModel($type);
|
||||
if ($class === null || ! class_exists($class)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user