DX: apply rector rules up to php8.0

This commit is contained in:
2023-04-15 01:05:37 +02:00
parent d8870e906f
commit dde3002100
714 changed files with 2348 additions and 9263 deletions

View File

@@ -28,14 +28,8 @@ use function trim;
final class AddressReferenceAPIController extends ApiController
{
private AddressReferenceRepository $addressReferenceRepository;
private PaginatorFactory $paginatorFactory;
public function __construct(AddressReferenceRepository $addressReferenceRepository, PaginatorFactory $paginatorFactory)
public function __construct(private AddressReferenceRepository $addressReferenceRepository, private PaginatorFactory $paginatorFactory)
{
$this->addressReferenceRepository = $addressReferenceRepository;
$this->paginatorFactory = $paginatorFactory;
}
/**

View File

@@ -23,20 +23,8 @@ use Symfony\Component\Serializer\SerializerInterface;
class AddressToReferenceMatcherController
{
private Security $security;
private EntityManagerInterface $entityManager;
private SerializerInterface $serializer;
public function __construct(
Security $security,
EntityManagerInterface $entityManager,
SerializerInterface $serializer
) {
$this->security = $security;
$this->entityManager = $entityManager;
$this->serializer = $serializer;
public function __construct(private Security $security, private EntityManagerInterface $entityManager, private SerializerInterface $serializer)
{
}
/**

View File

@@ -47,10 +47,8 @@ class CenterController extends AbstractController
/**
* Displays a form to edit an existing Center entity.
*
* @param mixed $id
*/
public function editAction($id)
public function editAction(mixed $id)
{
$em = $this->getDoctrine()->getManager();
@@ -98,10 +96,8 @@ class CenterController extends AbstractController
/**
* Finds and displays a Center entity.
*
* @param mixed $id
*/
public function showAction($id)
public function showAction(mixed $id)
{
$em = $this->getDoctrine()->getManager();
@@ -118,10 +114,8 @@ class CenterController extends AbstractController
/**
* Edits an existing Center entity.
*
* @param mixed $id
*/
public function updateAction(Request $request, $id)
public function updateAction(Request $request, mixed $id)
{
$em = $this->getDoctrine()->getManager();

View File

@@ -47,54 +47,8 @@ use function unserialize;
*/
class ExportController extends AbstractController
{
private EntityManagerInterface $entityManager;
/**
* @var ExportManager
*/
private $exportManager;
/**
* @var FormFactoryInterface
*/
private $formFactory;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var ChillRedis
*/
private $redis;
/**
* @var SessionInterface
*/
private $session;
/**
* @var TranslatorInterface
*/
private $translator;
public function __construct(
ChillRedis $chillRedis,
ExportManager $exportManager,
FormFactoryInterface $formFactory,
LoggerInterface $logger,
SessionInterface $session,
TranslatorInterface $translator,
EntityManagerInterface $entityManager
) {
$this->entityManager = $entityManager;
$this->redis = $chillRedis;
$this->exportManager = $exportManager;
$this->formFactory = $formFactory;
$this->logger = $logger;
$this->session = $session;
$this->translator = $translator;
public function __construct(private ChillRedis $redis, private ExportManager $exportManager, private FormFactoryInterface $formFactory, private LoggerInterface $logger, private SessionInterface $session, private TranslatorInterface $translator, private EntityManagerInterface $entityManager)
{
}
public function downloadResultAction(Request $request, $alias)
@@ -221,22 +175,13 @@ class ExportController extends AbstractController
$step = $request->query->getAlpha('step', 'centers');
switch ($step) {
case 'centers':
return $this->selectCentersStep($request, $export, $alias);
case 'export':
return $this->exportFormStep($request, $export, $alias);
case 'formatter':
return $this->formatterFormStep($request, $export, $alias);
case 'generate':
return $this->forwardToGenerate($request, $export, $alias);
default:
throw $this->createNotFoundException("The given step '{$step}' is invalid");
}
return match ($step) {
'centers' => $this->selectCentersStep($request, $export, $alias),
'export' => $this->exportFormStep($request, $export, $alias),
'formatter' => $this->formatterFormStep($request, $export, $alias),
'generate' => $this->forwardToGenerate($request, $export, $alias),
default => throw $this->createNotFoundException("The given step '{$step}' is invalid"),
};
}
/**
@@ -284,13 +229,12 @@ class ExportController extends AbstractController
*
* @param string $alias
* @param array $data the data from previous step. Required for steps 'formatter' and 'generate_formatter'
* @param mixed $step
*/
protected function createCreateFormExport($alias, $step, $data = []): FormInterface
protected function createCreateFormExport($alias, mixed $step, $data = []): FormInterface
{
/** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager;
$isGenerate = strpos($step, 'generate_') === 0;
$isGenerate = str_starts_with($step, 'generate_');
$builder = $this->formFactory
->createNamedBuilder(null, FormType::class, [], [
@@ -341,7 +285,7 @@ class ExportController extends AbstractController
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function exportFormStep(Request $request, $export, $alias)
protected function exportFormStep(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias)
{
$exportManager = $this->exportManager;
@@ -405,7 +349,7 @@ class ExportController extends AbstractController
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function formatterFormStep(Request $request, $export, $alias)
protected function formatterFormStep(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias)
{
// check we have data from the previous step (export step)
$data = $this->session->get('export_step', null);
@@ -462,7 +406,7 @@ class ExportController extends AbstractController
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
protected function forwardToGenerate(Request $request, $export, $alias)
protected function forwardToGenerate(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias)
{
$dataCenters = $this->session->get('centers_step_raw', null);
$dataFormatter = $this->session->get('formatter_step_raw', null);
@@ -522,12 +466,10 @@ class ExportController extends AbstractController
}
/**
* @param \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export
* @param string $alias
*
* @return Response
*/
protected function selectCentersStep(Request $request, $export, $alias)
protected function selectCentersStep(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias)
{
/** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager;
@@ -608,7 +550,7 @@ class ExportController extends AbstractController
*
* @return string the next/current step
*/
private function getNextStep($step, $export, $reverse = false)
private function getNextStep($step, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $reverse = false)
{
switch ($step) {
case 'centers':

View File

@@ -24,30 +24,8 @@ use Symfony\Component\Serializer\SerializerInterface;
class GeographicalUnitByAddressApiController
{
private PaginatorFactory $paginatorFactory;
private GeographicalUnitRepositoryInterface $geographicalUnitRepository;
private Security $security;
private SerializerInterface $serializer;
/**
* @param PaginatorFactory $paginatorFactory
* @param GeographicalUnitRepositoryInterface $geographicalUnitRepository
* @param Security $security
* @param SerializerInterface $serializer
*/
public function __construct(
PaginatorFactory $paginatorFactory,
GeographicalUnitRepositoryInterface $geographicalUnitRepository,
Security $security,
SerializerInterface $serializer
) {
$this->paginatorFactory = $paginatorFactory;
$this->geographicalUnitRepository = $geographicalUnitRepository;
$this->security = $security;
$this->serializer = $serializer;
public function __construct(private PaginatorFactory $paginatorFactory, private GeographicalUnitRepositoryInterface $geographicalUnitRepository, private Security $security, private SerializerInterface $serializer)
{
}
/**

View File

@@ -33,28 +33,8 @@ use UnexpectedValueException;
*/
class NotificationApiController
{
private EntityManagerInterface $entityManager;
private NotificationRepository $notificationRepository;
private PaginatorFactory $paginatorFactory;
private Security $security;
private SerializerInterface $serializer;
public function __construct(
EntityManagerInterface $entityManager,
NotificationRepository $notificationRepository,
PaginatorFactory $paginatorFactory,
Security $security,
SerializerInterface $serializer
) {
$this->entityManager = $entityManager;
$this->notificationRepository = $notificationRepository;
$this->paginatorFactory = $paginatorFactory;
$this->security = $security;
$this->serializer = $serializer;
public function __construct(private EntityManagerInterface $entityManager, private NotificationRepository $notificationRepository, private PaginatorFactory $paginatorFactory, private Security $security, private SerializerInterface $serializer)
{
}
/**
@@ -116,20 +96,11 @@ class NotificationApiController
throw new RuntimeException('not possible to mark as read by this user');
}
switch ($target) {
case 'read':
$notification->markAsReadBy($user);
break;
case 'unread':
$notification->markAsUnreadBy($user);
break;
default:
throw new UnexpectedValueException("target not supported: {$target}");
}
match ($target) {
'read' => $notification->markAsReadBy($user),
'unread' => $notification->markAsUnreadBy($user),
default => throw new UnexpectedValueException("target not supported: {$target}"),
};
$this->entityManager->flush();

View File

@@ -41,44 +41,8 @@ use function in_array;
*/
class NotificationController extends AbstractController
{
private LoggerInterface $chillLogger;
private EntityManagerInterface $em;
private LoggerInterface $logger;
private NotificationHandlerManager $notificationHandlerManager;
private NotificationRepository $notificationRepository;
private PaginatorFactory $paginatorFactory;
private Security $security;
private TranslatorInterface $translator;
private UserRepository $userRepository;
public function __construct(
EntityManagerInterface $em,
LoggerInterface $chillLogger,
LoggerInterface $logger,
Security $security,
NotificationRepository $notificationRepository,
NotificationHandlerManager $notificationHandlerManager,
PaginatorFactory $paginatorFactory,
TranslatorInterface $translator,
UserRepository $userRepository
) {
$this->em = $em;
$this->logger = $logger;
$this->chillLogger = $chillLogger;
$this->security = $security;
$this->notificationRepository = $notificationRepository;
$this->notificationHandlerManager = $notificationHandlerManager;
$this->paginatorFactory = $paginatorFactory;
$this->translator = $translator;
$this->userRepository = $userRepository;
public function __construct(private EntityManagerInterface $em, private LoggerInterface $chillLogger, private LoggerInterface $logger, private Security $security, private NotificationRepository $notificationRepository, private NotificationHandlerManager $notificationHandlerManager, private PaginatorFactory $paginatorFactory, private TranslatorInterface $translator, private UserRepository $userRepository)
{
}
/**
@@ -117,7 +81,7 @@ class NotificationController extends AbstractController
try {
$handler = $this->notificationHandlerManager->getHandler($notification);
} catch (NotificationHandlerNotFound $e) {
} catch (NotificationHandlerNotFound) {
throw new BadRequestHttpException('no handler for this notification');
}

View File

@@ -96,7 +96,7 @@ class PasswordController extends AbstractController
/**
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
*/
public function recoverAction(Request $request)
public function recoverAction(Request $request): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
if (false === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) {
return new Response($this->translator->trans('You are not allowed '
@@ -164,7 +164,7 @@ class PasswordController extends AbstractController
*
* @return Response|\Symfony\Component\HttpFoundation\RedirectResponse
*/
public function requestRecoverAction(Request $request)
public function requestRecoverAction(Request $request): \Symfony\Component\HttpFoundation\Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
if (false === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) {
return new Response($this->translator->trans('You are not allowed '

View File

@@ -24,16 +24,8 @@ use function json_decode;
class PermissionApiController extends AbstractController
{
private DenormalizerInterface $denormalizer;
private Security $security;
public function __construct(
DenormalizerInterface $denormalizer,
Security $security
) {
$this->denormalizer = $denormalizer;
$this->security = $security;
public function __construct(private DenormalizerInterface $denormalizer, private Security $security)
{
}
/**

View File

@@ -34,46 +34,11 @@ use function array_key_exists;
*/
class PermissionsGroupController extends AbstractController
{
/**
* @var RoleHierarchy
*/
private $roleHierarchy;
/**
* @var RoleProvider
*/
private $roleProvider;
/**
* @var TranslatableStringHelper
*/
private $translatableStringHelper;
/**
* @var TranslatorInterface
*/
private $translator;
/**
* @var ValidatorInterface
*/
private $validator;
/**
* PermissionsGroupController constructor.
*/
public function __construct(
TranslatableStringHelper $translatableStringHelper,
RoleProvider $roleProvider,
RoleHierarchy $roleHierarchy,
TranslatorInterface $translator,
ValidatorInterface $validator
) {
$this->translatableStringHelper = $translatableStringHelper;
$this->roleProvider = $roleProvider;
$this->roleHierarchy = $roleHierarchy;
$this->translator = $translator;
$this->validator = $validator;
public function __construct(private TranslatableStringHelper $translatableStringHelper, private RoleProvider $roleProvider, private RoleHierarchy $roleHierarchy, private TranslatorInterface $translator, private ValidatorInterface $validator)
{
}
/**
@@ -214,7 +179,7 @@ class PermissionsGroupController extends AbstractController
try {
$permissionsGroup->removeRoleScope($roleScope);
} catch (RuntimeException $ex) {
} catch (RuntimeException) {
$this->addFlash(
'notice',
$this->translator->trans("The role '%role%' and circle "
@@ -260,10 +225,8 @@ class PermissionsGroupController extends AbstractController
/**
* Displays a form to edit an existing PermissionsGroup entity.
*
* @param mixed $id
*/
public function editAction($id)
public function editAction(mixed $id)
{
$em = $this->getDoctrine()->getManager();
@@ -338,10 +301,8 @@ class PermissionsGroupController extends AbstractController
/**
* Finds and displays a PermissionsGroup entity.
*
* @param mixed $id
*/
public function showAction($id)
public function showAction(mixed $id)
{
$em = $this->getDoctrine()->getManager();
@@ -393,10 +354,8 @@ class PermissionsGroupController extends AbstractController
/**
* Edits an existing PermissionsGroup entity.
*
* @param mixed $id
*/
public function updateAction(Request $request, $id)
public function updateAction(Request $request, mixed $id)
{
$em = $this->getDoctrine()->getManager();

View File

@@ -26,20 +26,8 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
final class PostalCodeAPIController extends ApiController
{
private CountryRepository $countryRepository;
private PaginatorFactory $paginatorFactory;
private PostalCodeRepositoryInterface $postalCodeRepository;
public function __construct(
CountryRepository $countryRepository,
PostalCodeRepositoryInterface $postalCodeRepository,
PaginatorFactory $paginatorFactory
) {
$this->countryRepository = $countryRepository;
$this->postalCodeRepository = $postalCodeRepository;
$this->paginatorFactory = $paginatorFactory;
public function __construct(private CountryRepository $countryRepository, private PostalCodeRepositoryInterface $postalCodeRepository, private PaginatorFactory $paginatorFactory)
{
}
/**

View File

@@ -36,44 +36,8 @@ use function count;
class SavedExportController
{
private EntityManagerInterface $entityManager;
private ExportManager $exportManager;
private FormFactoryInterface $formFactory;
private SavedExportRepositoryInterface $savedExportRepository;
private Security $security;
private SessionInterface $session;
private EngineInterface $templating;
private TranslatorInterface $translator;
private UrlGeneratorInterface $urlGenerator;
public function __construct(
EngineInterface $templating,
EntityManagerInterface $entityManager,
ExportManager $exportManager,
FormFactoryInterface $formBuilder,
SavedExportRepositoryInterface $savedExportRepository,
Security $security,
SessionInterface $session,
TranslatorInterface $translator,
UrlGeneratorInterface $urlGenerator
) {
$this->exportManager = $exportManager;
$this->entityManager = $entityManager;
$this->formFactory = $formBuilder;
$this->savedExportRepository = $savedExportRepository;
$this->security = $security;
$this->session = $session;
$this->templating = $templating;
$this->translator = $translator;
$this->urlGenerator = $urlGenerator;
public function __construct(private EngineInterface $templating, private EntityManagerInterface $entityManager, private ExportManager $exportManager, private FormFactoryInterface $formFactory, private SavedExportRepositoryInterface $savedExportRepository, private Security $security, private SessionInterface $session, private TranslatorInterface $translator, private UrlGeneratorInterface $urlGenerator)
{
}
/**

View File

@@ -47,10 +47,8 @@ class ScopeController extends AbstractController
/**
* Displays a form to edit an existing Scope entity.
*
* @param mixed $id
*/
public function editAction($id)
public function editAction(mixed $id)
{
$em = $this->getDoctrine()->getManager();
@@ -98,10 +96,8 @@ class ScopeController extends AbstractController
/**
* Finds and displays a Scope entity.
*
* @param mixed $id
*/
public function showAction($id)
public function showAction(mixed $id)
{
$em = $this->getDoctrine()->getManager();
@@ -118,10 +114,8 @@ class ScopeController extends AbstractController
/**
* Edits an existing Scope entity.
*
* @param mixed $id
*/
public function updateAction(Request $request, $id)
public function updateAction(Request $request, mixed $id)
{
$em = $this->getDoctrine()->getManager();

View File

@@ -36,24 +36,8 @@ use function reset;
*/
class SearchController extends AbstractController
{
protected PaginatorFactory $paginatorFactory;
protected SearchApi $searchApi;
protected SearchProvider $searchProvider;
protected TranslatorInterface $translator;
public function __construct(
SearchProvider $searchProvider,
TranslatorInterface $translator,
PaginatorFactory $paginatorFactory,
SearchApi $searchApi
) {
$this->searchProvider = $searchProvider;
$this->translator = $translator;
$this->paginatorFactory = $paginatorFactory;
$this->searchApi = $searchApi;
public function __construct(protected SearchProvider $searchProvider, protected TranslatorInterface $translator, protected PaginatorFactory $paginatorFactory, protected SearchApi $searchApi)
{
}
public function advancedSearchAction($name, Request $request)
@@ -64,7 +48,7 @@ class SearchController extends AbstractController
/** @var Chill\MainBundle\Search\HasAdvancedSearchFormInterface $variable */
$search = $this->searchProvider
->getHasAdvancedFormByName($name);
} catch (\Chill\MainBundle\Search\UnknowSearchNameException $e) {
} catch (\Chill\MainBundle\Search\UnknowSearchNameException) {
throw $this->createNotFoundException('no advanced search for '
. "{$name}");
}

View File

@@ -22,20 +22,8 @@ use function count;
class TimelineCenterController extends AbstractController
{
protected PaginatorFactory $paginatorFactory;
protected TimelineBuilder $timelineBuilder;
private Security $security;
public function __construct(
TimelineBuilder $timelineBuilder,
PaginatorFactory $paginatorFactory,
Security $security
) {
$this->timelineBuilder = $timelineBuilder;
$this->paginatorFactory = $paginatorFactory;
$this->security = $security;
public function __construct(protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private Security $security)
{
}
/**

View File

@@ -28,10 +28,8 @@ class UserApiController extends ApiController
* "_format": "json"
* }
* )
*
* @param mixed $_format
*/
public function currentLocation($_format): JsonResponse
public function currentLocation(mixed $_format): JsonResponse
{
return $this->json(
$this->getUser()->getCurrentLocation(),
@@ -49,10 +47,8 @@ class UserApiController extends ApiController
* "_format": "json"
* }
* )
*
* @param mixed $_format
*/
public function whoami($_format): JsonResponse
public function whoami(mixed $_format): JsonResponse
{
return $this->json(
$this->getUser(),

View File

@@ -38,37 +38,15 @@ class UserController extends CRUDController
{
public const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
protected ParameterBagInterface $parameterBag;
private LoggerInterface $logger;
private UserPasswordEncoderInterface $passwordEncoder;
private UserRepository $userRepository;
private ValidatorInterface $validator;
public function __construct(
LoggerInterface $chillLogger,
ValidatorInterface $validator,
UserPasswordEncoderInterface $passwordEncoder,
UserRepository $userRepository,
ParameterBagInterface $parameterBag
) {
$this->logger = $chillLogger;
$this->userRepository = $userRepository;
$this->validator = $validator;
$this->passwordEncoder = $passwordEncoder;
$this->parameterBag = $parameterBag;
public function __construct(private LoggerInterface $logger, private ValidatorInterface $validator, private UserPasswordEncoderInterface $passwordEncoder, private UserRepository $userRepository, protected ParameterBagInterface $parameterBag)
{
}
/**
* @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter",
* name="admin_user_add_groupcenter")
*
* @param mixed $uid
*/
public function addLinkGroupCenterAction(Request $request, $uid): Response
public function addLinkGroupCenterAction(Request $request, mixed $uid): Response
{
$em = $this->getDoctrine()->getManager();
@@ -122,11 +100,8 @@ class UserController extends CRUDController
/**
* @Route("/{_locale}/admin/main/user/{uid}/delete_link_groupcenter/{gcid}",
* name="admin_user_delete_groupcenter")
*
* @param mixed $uid
* @param mixed $gcid
*/
public function deleteLinkGroupCenterAction($uid, $gcid, Request $request): RedirectResponse
public function deleteLinkGroupCenterAction(mixed $uid, mixed $gcid, Request $request): RedirectResponse
{
$em = $this->getDoctrine()->getManager();
@@ -421,10 +396,8 @@ class UserController extends CRUDController
/**
* Creates a form to delete a link to a GroupCenter.
*
* @param mixed $request
*/
private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, $request): FormInterface
private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, mixed $request): FormInterface
{
$returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : [];

View File

@@ -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();

View File

@@ -39,32 +39,8 @@ use function count;
class WorkflowController extends AbstractController
{
private EntityManagerInterface $entityManager;
private EntityWorkflowManager $entityWorkflowManager;
private EntityWorkflowRepository $entityWorkflowRepository;
private PaginatorFactory $paginatorFactory;
private Registry $registry;
private Security $security;
private TranslatorInterface $translator;
private ValidatorInterface $validator;
public function __construct(EntityWorkflowManager $entityWorkflowManager, EntityWorkflowRepository $entityWorkflowRepository, ValidatorInterface $validator, PaginatorFactory $paginatorFactory, Registry $registry, EntityManagerInterface $entityManager, TranslatorInterface $translator, Security $security)
public function __construct(private EntityWorkflowManager $entityWorkflowManager, private EntityWorkflowRepository $entityWorkflowRepository, private ValidatorInterface $validator, private PaginatorFactory $paginatorFactory, private Registry $registry, private EntityManagerInterface $entityManager, private TranslatorInterface $translator, private Security $security)
{
$this->entityWorkflowManager = $entityWorkflowManager;
$this->entityWorkflowRepository = $entityWorkflowRepository;
$this->validator = $validator;
$this->paginatorFactory = $paginatorFactory;
$this->registry = $registry;
$this->entityManager = $entityManager;
$this->translator = $translator;
$this->security = $security;
}
/**