From 5dfbfa582ea16d20c8c7ead0afd6099c5229f24f Mon Sep 17 00:00:00 2001 From: Daniel Subiabre Date: Fri, 2 May 2025 13:30:16 +0200 Subject: [PATCH] Revert submission state processing to default api resource processor --- .../MatchCallSubmissionApiResource.php | 13 +++++++--- .../Matchfunding/MatchCallSubmission.php | 2 +- .../MatchCallSubmissionStatus.php | 2 ++ .../MatchCallSubmissionStateProcessor.php | 26 ------------------- 4 files changed, 12 insertions(+), 31 deletions(-) delete mode 100644 src/State/Matchfunding/MatchCallSubmissionStateProcessor.php diff --git a/src/ApiResource/Matchfunding/MatchCallSubmissionApiResource.php b/src/ApiResource/Matchfunding/MatchCallSubmissionApiResource.php index 02e7127..7738180 100644 --- a/src/ApiResource/Matchfunding/MatchCallSubmissionApiResource.php +++ b/src/ApiResource/Matchfunding/MatchCallSubmissionApiResource.php @@ -8,8 +8,8 @@ use App\ApiResource\Project\ProjectApiResource; use App\Dto\Matchfunding\MatchCallSubmissionCreationDto; use App\Entity\Matchfunding\MatchCallSubmission; use App\Entity\Matchfunding\MatchCallSubmissionStatus; +use App\State\ApiResourceStateProcessor; use App\State\ApiResourceStateProvider; -use App\State\Matchfunding\MatchCallSubmissionStateProcessor; /** * MatchCallSubmissions represent the will of a Project to be held under a MatchCall and receive matchfunding financement. @@ -18,13 +18,19 @@ use App\State\Matchfunding\MatchCallSubmissionStateProcessor; shortName: 'MatchCallSubmission', stateOptions: new Options(entityClass: MatchCallSubmission::class), provider: ApiResourceStateProvider::class, - processor: MatchCallSubmissionStateProcessor::class + processor: ApiResourceStateProcessor::class )] +#[API\GetCollection()] #[API\Post( input: MatchCallSubmissionCreationDto::class, securityPostDenormalize: 'is_granted("PROJECT_EDIT", object.project)', securityPostDenormalizeMessage: 'You do not have permission to submit that Project to a MatchCall' )] +#[API\Get()] +#[API\Patch( + security: 'is_granted("MATCHCALLSUBMISSION_EDIT", object)', + securityMessage: 'You do not have permission to edit this MatchCallSubmission' +)] class MatchCallSubmissionApiResource { #[API\ApiProperty(identifier: true, writable: false)] @@ -46,6 +52,5 @@ class MatchCallSubmissionApiResource * The status of the Project's application for the MatchCall.\ * Only MatchCallSubmissions with an status `accepted` will receive matchfunding. */ - #[API\ApiProperty(securityPostDenormalize: 'is_granted("MATCHCALLSUBMISSION_EDIT", object)')] - public MatchCallSubmissionStatus $status = MatchCallSubmissionStatus::ToReview; + public MatchCallSubmissionStatus $status = MatchCallSubmissionStatus::DEFAULT; } diff --git a/src/Entity/Matchfunding/MatchCallSubmission.php b/src/Entity/Matchfunding/MatchCallSubmission.php index 3c36eb5..141752f 100644 --- a/src/Entity/Matchfunding/MatchCallSubmission.php +++ b/src/Entity/Matchfunding/MatchCallSubmission.php @@ -26,7 +26,7 @@ class MatchCallSubmission private ?Project $project = null; #[ORM\Column(enumType: MatchCallSubmissionStatus::class)] - private ?MatchCallSubmissionStatus $status = null; + private ?MatchCallSubmissionStatus $status = MatchCallSubmissionStatus::DEFAULT; public function getId(): ?int { diff --git a/src/Entity/Matchfunding/MatchCallSubmissionStatus.php b/src/Entity/Matchfunding/MatchCallSubmissionStatus.php index 5003fcc..cd5c800 100644 --- a/src/Entity/Matchfunding/MatchCallSubmissionStatus.php +++ b/src/Entity/Matchfunding/MatchCallSubmissionStatus.php @@ -4,6 +4,8 @@ namespace App\Entity\Matchfunding; enum MatchCallSubmissionStatus: string { + public const DEFAULT = self::ToReview; + /** * The MatchCallSubmission is pending review. */ diff --git a/src/State/Matchfunding/MatchCallSubmissionStateProcessor.php b/src/State/Matchfunding/MatchCallSubmissionStateProcessor.php deleted file mode 100644 index ace9742..0000000 --- a/src/State/Matchfunding/MatchCallSubmissionStateProcessor.php +++ /dev/null @@ -1,26 +0,0 @@ -autoMapper->map($data, MatchCallSubmission::class); - } -}