Add basic entity processor
This commit is contained in:
@@ -2,25 +2,19 @@
|
||||
|
||||
namespace App\State\Project;
|
||||
|
||||
use ApiPlatform\Doctrine\Common\State\PersistProcessor;
|
||||
use ApiPlatform\Doctrine\Common\State\RemoveProcessor;
|
||||
use ApiPlatform\Metadata\DeleteOperationInterface;
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProcessorInterface;
|
||||
use App\ApiResource\Project\ProjectApiResource;
|
||||
use App\Entity\Project\Project;
|
||||
use App\Mapping\AutoMapper;
|
||||
use App\Service\Auth\AuthService;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
use App\State\EntityStateProcessor;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
|
||||
class ProjectStateProcessor implements ProcessorInterface
|
||||
{
|
||||
public function __construct(
|
||||
#[Autowire(service: RemoveProcessor::class)]
|
||||
private ProcessorInterface $deleteProcessor,
|
||||
#[Autowire(service: PersistProcessor::class)]
|
||||
private ProcessorInterface $persistProcessor,
|
||||
private EntityStateProcessor $entityStateProcessor,
|
||||
private AutoMapper $autoMapper,
|
||||
private AuthService $authService,
|
||||
) {}
|
||||
@@ -45,13 +39,7 @@ class ProjectStateProcessor implements ProcessorInterface
|
||||
$project->setOwner($owner);
|
||||
}
|
||||
|
||||
if ($operation instanceof DeleteOperationInterface) {
|
||||
$this->deleteProcessor->process($project, $operation, $uriVariables, $context);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->persistProcessor->process($project, $operation, $uriVariables, $context);
|
||||
$project = $this->entityStateProcessor->process($project, $operation, $uriVariables, $context);
|
||||
|
||||
return $this->autoMapper->map($project, $data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user