mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 06:44:59 +00:00
DX: apply rector rules up to php8.0
This commit is contained in:
@@ -30,28 +30,8 @@ use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
class WorkflowApiController
|
||||
{
|
||||
private EntityManagerInterface $entityManager;
|
||||
|
||||
private EntityWorkflowRepository $entityWorkflowRepository;
|
||||
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
private Security $security;
|
||||
|
||||
private SerializerInterface $serializer;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $entityManager,
|
||||
EntityWorkflowRepository $entityWorkflowRepository,
|
||||
PaginatorFactory $paginatorFactory,
|
||||
Security $security,
|
||||
SerializerInterface $serializer
|
||||
) {
|
||||
$this->entityManager = $entityManager;
|
||||
$this->entityWorkflowRepository = $entityWorkflowRepository;
|
||||
$this->paginatorFactory = $paginatorFactory;
|
||||
$this->security = $security;
|
||||
$this->serializer = $serializer;
|
||||
public function __construct(private EntityManagerInterface $entityManager, private EntityWorkflowRepository $entityWorkflowRepository, private PaginatorFactory $paginatorFactory, private Security $security, private SerializerInterface $serializer)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,46 +140,19 @@ class WorkflowApiController
|
||||
|
||||
$user = $this->security->getUser();
|
||||
|
||||
switch ($request->query->get('subscribe')) {
|
||||
case 'final':
|
||||
switch ($action) {
|
||||
case 'subscribe':
|
||||
$entityWorkflow->addSubscriberToFinal($user);
|
||||
|
||||
break;
|
||||
|
||||
case 'unsubscribe':
|
||||
$entityWorkflow->removeSubscriberToFinal($user);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new LogicException();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'step':
|
||||
switch ($action) {
|
||||
case 'subscribe':
|
||||
$entityWorkflow->addSubscriberToStep($user);
|
||||
|
||||
break;
|
||||
|
||||
case 'unsubscribe':
|
||||
$entityWorkflow->removeSubscriberToStep($user);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new LogicException();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new BadRequestHttpException('subscribe parameter must be equal to "step" or "final"');
|
||||
}
|
||||
match ($request->query->get('subscribe')) {
|
||||
'final' => match ($action) {
|
||||
'subscribe' => $entityWorkflow->addSubscriberToFinal($user),
|
||||
'unsubscribe' => $entityWorkflow->removeSubscriberToFinal($user),
|
||||
default => throw new LogicException(),
|
||||
},
|
||||
'step' => match ($action) {
|
||||
'subscribe' => $entityWorkflow->addSubscriberToStep($user),
|
||||
'unsubscribe' => $entityWorkflow->removeSubscriberToStep($user),
|
||||
default => throw new LogicException(),
|
||||
},
|
||||
default => throw new BadRequestHttpException('subscribe parameter must be equal to "step" or "final"'),
|
||||
};
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
|
Reference in New Issue
Block a user