Revert submission state processing to default api resource processor

This commit is contained in:
2025-05-02 13:30:16 +02:00
parent 0d0215ae44
commit 5dfbfa582e
4 changed files with 12 additions and 31 deletions
@@ -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;
}
@@ -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
{
@@ -4,6 +4,8 @@ namespace App\Entity\Matchfunding;
enum MatchCallSubmissionStatus: string
{
public const DEFAULT = self::ToReview;
/**
* The MatchCallSubmission is pending review.
*/
@@ -1,26 +0,0 @@
<?php
namespace App\State\Matchfunding;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use App\ApiResource\Matchfunding\MatchCallSubmissionApiResource;
use App\Dto\Matchfunding\MatchCallSubmissionCreationDto;
use App\Entity\Matchfunding\MatchCallSubmission;
use App\Mapping\AutoMapper;
class MatchCallSubmissionStateProcessor implements ProcessorInterface
{
public function __construct(
private AutoMapper $autoMapper
) {}
/**
* @param MatchCallSubmissionApiResource|MatchCallSubmissionCreationDto $data
*/
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = [])
{
dd($data);
$entity = $this->autoMapper->map($data, MatchCallSubmission::class);
}
}