Apply rector rules: symfony up to 54

This commit is contained in:
2024-04-04 23:30:25 +02:00
parent 1ee3b9e2f0
commit 579bd829f8
204 changed files with 974 additions and 2346 deletions

View File

@@ -21,13 +21,7 @@ class AbsenceController extends AbstractController
{
public function __construct(private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
/**
* @Route(
* "/{_locale}/absence",
* name="chill_main_user_absence_index",
* methods={"GET", "POST"}
* )
*/
#[Route(path: '/{_locale}/absence', name: 'chill_main_user_absence_index', methods: ['GET', 'POST'])]
public function setAbsence(Request $request)
{
$user = $this->security->getUser();
@@ -48,13 +42,7 @@ class AbsenceController extends AbstractController
]);
}
/**
* @Route(
* "/{_locale}/absence/unset",
* name="chill_main_user_absence_unset",
* methods={"GET", "POST"}
* )
*/
#[Route(path: '/{_locale}/absence/unset', name: 'chill_main_user_absence_unset', methods: ['GET', 'POST'])]
public function unsetAbsence(Request $request)
{
$user = $this->security->getUser();

View File

@@ -24,10 +24,8 @@ class AddressApiController extends ApiController
/**
* Duplicate an existing address.
*
* @Route("/api/1.0/main/address/{id}/duplicate.json", name="chill_api_main_address_duplicate",
* methods={"POST"})
*/
#[Route(path: '/api/1.0/main/address/{id}/duplicate.json', name: 'chill_api_main_address_duplicate', methods: ['POST'])]
public function duplicate(Address $address): JsonResponse
{
$this->denyAccessUnlessGranted('ROLE_USER');

View File

@@ -28,9 +28,7 @@ final class AddressReferenceAPIController extends ApiController
{
public function __construct(private readonly AddressReferenceRepository $addressReferenceRepository, private readonly PaginatorFactory $paginatorFactory) {}
/**
* @Route("/api/1.0/main/address-reference/by-postal-code/{id}/search.json")
*/
#[Route(path: '/api/1.0/main/address-reference/by-postal-code/{id}/search.json')]
public function search(PostalCode $postalCode, Request $request): JsonResponse
{
$this->denyAccessUnlessGranted('ROLE_USER');

View File

@@ -25,9 +25,7 @@ class AddressToReferenceMatcherController
{
public function __construct(private readonly Security $security, private readonly EntityManagerInterface $entityManager, private readonly SerializerInterface $serializer) {}
/**
* @Route("/api/1.0/main/address/reference-match/{id}/set/reviewed", methods={"POST"})
*/
#[Route(path: '/api/1.0/main/address/reference-match/{id}/set/reviewed', methods: ['POST'])]
public function markAddressAsReviewed(Address $address): JsonResponse
{
if (!$this->security->isGranted('ROLE_USER')) {
@@ -48,9 +46,8 @@ class AddressToReferenceMatcherController
/**
* Set an address back to "to review". Only if the address is in "reviewed" state.
*
* @Route("/api/1.0/main/address/reference-match/{id}/set/to_review", methods={"POST"})
*/
#[Route(path: '/api/1.0/main/address/reference-match/{id}/set/to_review', methods: ['POST'])]
public function markAddressAsToReview(Address $address): JsonResponse
{
if (!$this->security->isGranted('ROLE_USER')) {
@@ -73,9 +70,7 @@ class AddressToReferenceMatcherController
);
}
/**
* @Route("/api/1.0/main/address/reference-match/{id}/sync-with-reference", methods={"POST"})
*/
#[Route(path: '/api/1.0/main/address/reference-match/{id}/sync-with-reference', methods: ['POST'])]
public function syncAddressWithReference(Address $address): JsonResponse
{
if (null === $address->getAddressReference()) {

View File

@@ -16,41 +16,31 @@ use Symfony\Component\Routing\Annotation\Route;
class AdminController extends AbstractController
{
/**
* @Route("/{_locale}/admin", name="chill_main_admin_central")
*/
#[Route(path: '/{_locale}/admin', name: 'chill_main_admin_central')]
public function indexAction()
{
return $this->render('@ChillMain/Admin/index.html.twig');
}
/**
* @Route("/{_locale}/admin/language", name="chill_main_language_admin")
*/
#[Route(path: '/{_locale}/admin/language', name: 'chill_main_language_admin')]
public function indexLanguageAction()
{
return $this->render('@ChillMain/Admin/indexLanguage.html.twig');
}
/**
* @Route("/{_locale}/admin/location", name="chill_main_location_admin")
*/
#[Route(path: '/{_locale}/admin/location', name: 'chill_main_location_admin')]
public function indexLocationAction()
{
return $this->render('@ChillMain/Admin/indexLocation.html.twig');
}
/**
* @Route("/{_locale}/admin/user", name="chill_main_user_admin")
*/
#[Route(path: '/{_locale}/admin/user', name: 'chill_main_user_admin')]
public function indexUserAction()
{
return $this->render('@ChillMain/Admin/indexUser.html.twig');
}
/**
* @Route("/{_locale}/admin/dashboard", name="chill_main_dashboard_admin")
*/
#[Route(path: '/{_locale}/admin/dashboard', name: 'chill_main_dashboard_admin')]
public function indexDashboardAction()
{
return $this->render('@ChillMain/Admin/indexDashboard.html.twig');

View File

@@ -24,9 +24,8 @@ final readonly class DashboardApiController
/**
* Get user dashboard config (not yet based on user id and still hardcoded for now).
*
* @Route("/api/1.0/main/dashboard-config-item.json", methods={"get"})
*/
#[Route(path: '/api/1.0/main/dashboard-config-item.json', methods: ['get'])]
public function getDashboardConfiguration(): JsonResponse
{
$data = [];

View File

@@ -18,9 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
*/
class DefaultController extends AbstractController
{
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/homepage", name="chill_main_homepage")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/homepage', name: 'chill_main_homepage')]
public function indexAction()
{
if ($this->isGranted('ROLE_ADMIN')) {
@@ -30,9 +28,7 @@ class DefaultController extends AbstractController
return $this->render('@ChillMain/layout.html.twig');
}
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/homepage", name="chill_main_homepage_without_locale")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/homepage', name: 'chill_main_homepage_without_locale')]
public function indexWithoutLocaleAction()
{
return $this->redirectToRoute('chill_main_homepage');

View File

@@ -65,9 +65,7 @@ class ExportController extends AbstractController
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/exports/download/{alias}", name="chill_main_export_download", methods={"GET"})
*/
#[Route(path: '/{_locale}/exports/download/{alias}', name: 'chill_main_export_download', methods: ['GET'])]
public function downloadResultAction(Request $request, mixed $alias)
{
/** @var ExportManager $exportManager */
@@ -109,9 +107,11 @@ class ExportController extends AbstractController
* @param string $alias
*
* @return Response
* @return Response
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/exports/generate/{alias}", name="chill_main_export_generate", methods={"GET"})
*/
#[Route(path: '/{_locale}/exports/generate/{alias}', name: 'chill_main_export_generate', methods: ['GET'])]
public function generateAction(Request $request, $alias)
{
/** @var ExportManager $exportManager */
@@ -130,10 +130,9 @@ class ExportController extends AbstractController
}
/**
* @Route("/{_locale}/exports/generate-from-saved/{id}", name="chill_main_export_generate_from_saved")
*
* @throws \RedisException
*/
#[Route(path: '/{_locale}/exports/generate-from-saved/{id}', name: 'chill_main_export_generate_from_saved')]
public function generateFromSavedExport(SavedExport $savedExport): RedirectResponse
{
$this->denyAccessUnlessGranted(SavedExportVoter::GENERATE, $savedExport);
@@ -154,9 +153,8 @@ class ExportController extends AbstractController
/**
* Render the list of available exports.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/exports/", name="chill_main_export_index")
*/
#[Route(path: '/{_locale}/exports/', name: 'chill_main_export_index')]
public function indexAction(): Response
{
$exportManager = $this->exportManager;
@@ -179,9 +177,8 @@ class ExportController extends AbstractController
* stored in the session (if valid), and then a redirection is done to next step.
* 3. 'generate': gather data from session from the previous steps, and
* make a redirection to the "generate" action with data in query (HTTP GET)
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/exports/new/{alias}", name="chill_main_export_new")
*/
#[Route(path: '/{_locale}/exports/new/{alias}', name: 'chill_main_export_new')]
public function newAction(Request $request, string $alias): Response
{
// first check for ACL
@@ -205,9 +202,7 @@ class ExportController extends AbstractController
};
}
/**
* @Route("/{_locale}/export/saved/update-from-key/{id}/{key}", name="chill_main_export_saved_edit_options_from_key")
*/
#[Route(path: '/{_locale}/export/saved/update-from-key/{id}/{key}', name: 'chill_main_export_saved_edit_options_from_key')]
public function editSavedExportOptionsFromKey(SavedExport $savedExport, string $key): Response
{
$this->denyAccessUnlessGranted('ROLE_USER');
@@ -227,9 +222,7 @@ class ExportController extends AbstractController
return $this->redirectToRoute('chill_main_export_saved_edit', ['id' => $savedExport->getId()]);
}
/**
* @Route("/{_locale}/export/save-from-key/{alias}/{key}", name="chill_main_export_save_from_key")
*/
#[Route(path: '/{_locale}/export/save-from-key/{alias}/{key}', name: 'chill_main_export_save_from_key')]
public function saveFromKey(string $alias, string $key, Request $request): Response
{
$this->denyAccessUnlessGranted('ROLE_USER');

View File

@@ -26,9 +26,7 @@ class GeographicalUnitByAddressApiController
{
public function __construct(private readonly PaginatorFactory $paginatorFactory, private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository, private readonly Security $security, private readonly SerializerInterface $serializer) {}
/**
* @Route("/api/1.0/main/geographical-unit/by-address/{id}.{_format}", requirements={"_format": "json"})
*/
#[Route(path: '/api/1.0/main/geographical-unit/by-address/{id}.{_format}', requirements: ['_format' => 'json'])]
public function getGeographicalUnitCoveringAddress(Address $address): JsonResponse
{
if (!$this->security->isGranted('ROLE_USER')) {

View File

@@ -35,9 +35,11 @@ class LoginController extends AbstractController
* Show a login form.
*
* @return Response
* @return Response
*
* @\Symfony\Component\Routing\Annotation\Route(path="/login", name="login")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/login', name: 'login')]
public function loginAction(Request $request)
{
return $this->render('@ChillMain/Login/login.html.twig', [

View File

@@ -29,9 +29,8 @@ class NewsItemApiController
/**
* Get list of news items filtered on start and end date.
*
* @Route("/api/1.0/main/news/current.json", methods={"get"})
*/
#[Route(path: '/api/1.0/main/news/current.json', methods: ['get'])]
public function listCurrentNewsItems(): JsonResponse
{
$total = $this->newsItemRepository->countCurrentNews();

View File

@@ -30,9 +30,7 @@ final readonly class NewsItemHistoryController
private readonly Environment $environment,
) {}
/**
* @Route("/{_locale}/news-items/history", name="chill_main_news_items_history")
*/
#[Route(path: '/{_locale}/news-items/history', name: 'chill_main_news_items_history')]
public function list(): Response
{
$filter = $this->buildFilterOrder();
@@ -48,9 +46,7 @@ final readonly class NewsItemHistoryController
]));
}
/**
* @Route("/{_locale}/news-items/{id}", name="chill_main_single_news_item")
*/
#[Route(path: '/{_locale}/news-items/{id}', name: 'chill_main_single_news_item')]
public function showSingleItem(NewsItem $newsItem, Request $request): Response
{
return new Response($this->environment->render(

View File

@@ -26,32 +26,24 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/api/1.0/main/notification")
*/
#[Route(path: '/api/1.0/main/notification')]
class NotificationApiController
{
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly NotificationRepository $notificationRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer) {}
/**
* @Route("/{id}/mark/read", name="chill_api_main_notification_mark_read", methods={"POST"})
*/
#[Route(path: '/{id}/mark/read', name: 'chill_api_main_notification_mark_read', methods: ['POST'])]
public function markAsRead(Notification $notification): JsonResponse
{
return $this->markAs('read', $notification);
}
/**
* @Route("/{id}/mark/unread", name="chill_api_main_notification_mark_unread", methods={"POST"})
*/
#[Route(path: '/{id}/mark/unread', name: 'chill_api_main_notification_mark_unread', methods: ['POST'])]
public function markAsUnread(Notification $notification): JsonResponse
{
return $this->markAs('unread', $notification);
}
/**
* @Route("/my/unread")
*/
#[Route(path: '/my/unread')]
public function myUnreadNotifications(Request $request): JsonResponse
{
$total = $this->notificationRepository->countUnreadByUser($this->security->getUser());

View File

@@ -35,16 +35,12 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
/**
* @Route("/{_locale}/notification")
*/
#[Route(path: '/{_locale}/notification')]
class NotificationController extends AbstractController
{
public function __construct(private readonly EntityManagerInterface $em, private readonly LoggerInterface $chillLogger, private readonly LoggerInterface $logger, private readonly ChillSecurity $security, private readonly NotificationRepository $notificationRepository, private readonly NotificationHandlerManager $notificationHandlerManager, private readonly PaginatorFactory $paginatorFactory, private readonly TranslatorInterface $translator, private readonly UserRepository $userRepository, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
/**
* @Route("/create", name="chill_main_notification_create")
*/
#[Route(path: '/create', name: 'chill_main_notification_create')]
public function createAction(Request $request): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
@@ -102,9 +98,7 @@ class NotificationController extends AbstractController
]);
}
/**
* @Route("/{id}/edit", name="chill_main_notification_edit")
*/
#[Route(path: '/{id}/edit', name: 'chill_main_notification_edit')]
public function editAction(Notification $notification, Request $request): Response
{
$this->denyAccessUnlessGranted(NotificationVoter::NOTIFICATION_UPDATE, $notification);
@@ -132,9 +126,7 @@ class NotificationController extends AbstractController
]);
}
/**
* @Route("/{id}/access_key", name="chill_main_notification_grant_access_by_access_key")
*/
#[Route(path: '/{id}/access_key', name: 'chill_main_notification_grant_access_by_access_key')]
public function getAccessByAccessKey(Notification $notification, Request $request): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
@@ -174,9 +166,7 @@ class NotificationController extends AbstractController
return $this->redirectToRoute('chill_main_notification_show', ['id' => $notification->getId()]);
}
/**
* @Route("/inbox", name="chill_main_notification_my")
*/
#[Route(path: '/inbox', name: 'chill_main_notification_my')]
public function inboxAction(): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
@@ -200,9 +190,7 @@ class NotificationController extends AbstractController
]);
}
/**
* @Route("/sent", name="chill_main_notification_sent")
*/
#[Route(path: '/sent', name: 'chill_main_notification_sent')]
public function sentAction(): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
@@ -226,9 +214,7 @@ class NotificationController extends AbstractController
]);
}
/**
* @Route("/{id}/show", name="chill_main_notification_show")
*/
#[Route(path: '/{id}/show', name: 'chill_main_notification_show')]
public function showAction(Notification $notification, Request $request): Response
{
$this->denyAccessUnlessGranted(NotificationVoter::NOTIFICATION_SEE, $notification);

View File

@@ -27,7 +27,6 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -40,21 +39,18 @@ final class PasswordController extends AbstractController
/**
* PasswordController constructor.
*/
public function __construct(private readonly LoggerInterface $chillLogger, private readonly UserPasswordEncoderInterface $passwordEncoder, private readonly RecoverPasswordHelper $recoverPasswordHelper, private readonly TokenManager $tokenManager, private readonly TranslatorInterface $translator, private readonly EventDispatcherInterface $eventDispatcher, private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
public function __construct(private readonly LoggerInterface $chillLogger, private readonly \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface $passwordEncoder, private readonly RecoverPasswordHelper $recoverPasswordHelper, private readonly TokenManager $tokenManager, private readonly TranslatorInterface $translator, private readonly EventDispatcherInterface $eventDispatcher, private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
/**
* @return Response
*
* @\Symfony\Component\Routing\Annotation\Route(path="/public/{_locale}/password/request-changed", name="password_request_recover_changed")
*/
#[Route(path: '/public/{_locale}/password/request-changed', name: 'password_request_recover_changed')]
public function changeConfirmedAction()
{
return $this->render('@ChillMain/Password/recover_password_changed.html.twig');
}
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/public/{_locale}/password/recover", name="password_recover")
*/
#[Route(path: '/public/{_locale}/password/recover', name: 'password_recover')]
public function recoverAction(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
if (false === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) {
@@ -96,7 +92,7 @@ final class PasswordController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$password = $form->get('new_password')->getData();
$user->setPassword($this->passwordEncoder->encodePassword($user, $password));
$user->setPassword($this->passwordEncoder->hashPassword($user, $password));
// logging for prod
$this
->chillLogger
@@ -120,9 +116,11 @@ final class PasswordController extends AbstractController
/**
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*
* @\Symfony\Component\Routing\Annotation\Route(path="/public/{_locale}/password/request-recover", name="password_request_recover")
*/
#[Route(path: '/public/{_locale}/password/request-recover', name: 'password_request_recover')]
public function requestRecoverAction(Request $request): Response|\Symfony\Component\HttpFoundation\RedirectResponse
{
if (false === $this->isGranted(PasswordRecoverVoter::ASK_TOKEN)) {
@@ -193,9 +191,8 @@ final class PasswordController extends AbstractController
/**
* @return Response
*
* @\Symfony\Component\Routing\Annotation\Route(path="/public/{_locale}/password/request-confirm", name="password_request_recover_confirm")
*/
#[Route(path: '/public/{_locale}/password/request-confirm', name: 'password_request_recover_confirm')]
public function requestRecoverConfirmAction()
{
return $this->render('@ChillMain/Password/request_recover_password_confirm.html.twig');
@@ -203,9 +200,8 @@ final class PasswordController extends AbstractController
/**
* @return Response
*
* @Route("/{_locale}/my/password", name="change_my_password")
*/
#[Route(path: '/{_locale}/my/password', name: 'change_my_password')]
public function UserPasswordAction(Request $request)
{
if (!$this->security->isGranted('ROLE_USER')) {
@@ -234,7 +230,7 @@ final class PasswordController extends AbstractController
]
);
$user->setPassword($this->passwordEncoder->encodePassword($user, $password));
$user->setPassword($this->passwordEncoder->hashPassword($user, $password));
$em = $this->managerRegistry->getManager();
$em->flush();

View File

@@ -24,10 +24,9 @@ class PermissionApiController extends AbstractController
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly Security $security) {}
/**
* @Route("/api/1.0/main/permissions/info.json", methods={"POST"})
*
* @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
*/
#[Route(path: '/api/1.0/main/permissions/info.json', methods: ['POST'])]
public function getPermissions(Request $request): JsonResponse
{
$this->denyAccessUnlessGranted('ROLE_USER');

View File

@@ -49,9 +49,7 @@ final class PermissionsGroupController extends AbstractController
private readonly RoleScopeRepository $roleScopeRepository,
) {}
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/{id}/add_link_role_scope", name="admin_permissionsgroup_add_role_scope", methods={"PUT"})
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{id}/add_link_role_scope', name: 'admin_permissionsgroup_add_role_scope', methods: ['PUT'])]
public function addLinkRoleScopeAction(Request $request, int $id): Response
{
$permissionsGroup = $this->permissionsGroupRepository->find($id);
@@ -129,9 +127,8 @@ final class PermissionsGroupController extends AbstractController
/**
* Creates a new PermissionsGroup entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/create", name="admin_permissionsgroup_create", methods={"POST"})
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/create', name: 'admin_permissionsgroup_create', methods: ['POST'])]
public function createAction(Request $request): Response
{
$permissionsGroup = new PermissionsGroup();
@@ -153,9 +150,8 @@ final class PermissionsGroupController extends AbstractController
/**
* remove an association between permissionsGroup and roleScope.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/{pgid}/delete_link_role_scope/{rsid}", name="admin_permissionsgroup_delete_role_scope", methods={"DELETE"})
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{pgid}/delete_link_role_scope/{rsid}', name: 'admin_permissionsgroup_delete_role_scope', methods: ['DELETE'])]
public function deleteLinkRoleScopeAction(int $pgid, int $rsid): Response
{
$permissionsGroup = $this->permissionsGroupRepository->find($pgid);
@@ -211,9 +207,8 @@ final class PermissionsGroupController extends AbstractController
/**
* Displays a form to edit an existing PermissionsGroup entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/{id}/edit", name="admin_permissionsgroup_edit")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{id}/edit', name: 'admin_permissionsgroup_edit')]
public function editAction(int $id): Response
{
$permissionsGroup = $this->permissionsGroupRepository->find($id);
@@ -259,9 +254,8 @@ final class PermissionsGroupController extends AbstractController
/**
* Lists all PermissionsGroup entities.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/", name="admin_permissionsgroup")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/', name: 'admin_permissionsgroup')]
public function indexAction(): Response
{
$entities = $this->permissionsGroupRepository->findAllOrderedAlphabetically();
@@ -273,9 +267,8 @@ final class PermissionsGroupController extends AbstractController
/**
* Displays a form to create a new PermissionsGroup entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/new", name="admin_permissionsgroup_new")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/new', name: 'admin_permissionsgroup_new')]
public function newAction(): Response
{
$permissionsGroup = new PermissionsGroup();
@@ -289,9 +282,8 @@ final class PermissionsGroupController extends AbstractController
/**
* Finds and displays a PermissionsGroup entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/{id}/show", name="admin_permissionsgroup_show")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{id}/show', name: 'admin_permissionsgroup_show')]
public function showAction(int $id): Response
{
$permissionsGroup = $this->permissionsGroupRepository->find($id);
@@ -342,9 +334,8 @@ final class PermissionsGroupController extends AbstractController
/**
* Edits an existing PermissionsGroup entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/permissionsgroup/{id}/update", name="admin_permissionsgroup_update", methods={"POST", "PUT"})
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/permissionsgroup/{id}/update', name: 'admin_permissionsgroup_update', methods: ['POST', 'PUT'])]
public function updateAction(Request $request, int $id): Response
{
$permissionsGroup = $this->permissionsGroupRepository

View File

@@ -28,9 +28,7 @@ final class PostalCodeAPIController extends ApiController
{
public function __construct(private readonly CountryRepository $countryRepository, private readonly PostalCodeRepositoryInterface $postalCodeRepository, private readonly PaginatorFactory $paginatorFactory) {}
/**
* @Route("/api/1.0/main/postal-code/search.json")
*/
#[Route(path: '/api/1.0/main/postal-code/search.json')]
public function search(Request $request): JsonResponse
{
$this->denyAccessUnlessGranted('ROLE_USER');

View File

@@ -35,12 +35,9 @@ class PostalCodeController extends AbstractController
}
/**
* @Route(
* "{_locale}/postalcode/search"
* )
*
* @return JsonResponse
*/
#[Route(path: '{_locale}/postalcode/search')]
public function searchAction(Request $request)
{
$pattern = $request->query->getAlnum('q', '');

View File

@@ -36,9 +36,7 @@ class SavedExportController
{
public function __construct(private readonly \Twig\Environment $templating, private readonly EntityManagerInterface $entityManager, private readonly ExportManager $exportManager, private readonly FormFactoryInterface $formFactory, private readonly SavedExportRepositoryInterface $savedExportRepository, private readonly Security $security, private readonly SessionInterface $session, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator) {}
/**
* @Route("/{_locale}/exports/saved/{id}/delete", name="chill_main_export_saved_delete")
*/
#[Route(path: '/{_locale}/exports/saved/{id}/delete', name: 'chill_main_export_saved_delete')]
public function delete(SavedExport $savedExport, Request $request): Response
{
if (!$this->security->isGranted(SavedExportVoter::DELETE, $savedExport)) {
@@ -71,9 +69,7 @@ class SavedExportController
);
}
/**
* @Route("/{_locale}/exports/saved/{id}/edit", name="chill_main_export_saved_edit")
*/
#[Route(path: '/{_locale}/exports/saved/{id}/edit', name: 'chill_main_export_saved_edit')]
public function edit(SavedExport $savedExport, Request $request): Response
{
if (!$this->security->isGranted(SavedExportVoter::EDIT, $savedExport)) {
@@ -104,9 +100,7 @@ class SavedExportController
);
}
/**
* @Route("/{_locale}/exports/saved/my", name="chill_main_export_saved_list_my")
*/
#[Route(path: '/{_locale}/exports/saved/my', name: 'chill_main_export_saved_list_my')]
public function list(): Response
{
$user = $this->security->getUser();

View File

@@ -32,9 +32,8 @@ class ScopeController extends AbstractController
/**
* Creates a new Scope entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/scope/create", name="admin_scope_create", methods={"POST"})
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/scope/create', name: 'admin_scope_create', methods: ['POST'])]
public function createAction(Request $request)
{
$scope = new Scope();
@@ -57,9 +56,8 @@ class ScopeController extends AbstractController
/**
* Displays a form to edit an existing Scope entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/scope/{id}/edit", name="admin_scope_edit")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/scope/{id}/edit', name: 'admin_scope_edit')]
public function editAction(Scope $scope, Request $request): Response
{
$editForm = $this->createEditForm($scope);
@@ -79,9 +77,8 @@ class ScopeController extends AbstractController
/**
* Lists all Scope entities.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/scope/", name="admin_scope")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/scope/', name: 'admin_scope')]
public function indexAction()
{
$em = $this->managerRegistry->getManager();
@@ -95,9 +92,8 @@ class ScopeController extends AbstractController
/**
* Displays a form to create a new Scope entity.
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/scope/new", name="admin_scope_new")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/admin/scope/new', name: 'admin_scope_new')]
public function newAction()
{
$scope = new Scope();

View File

@@ -34,9 +34,7 @@ class SearchController extends AbstractController
{
public function __construct(protected SearchProvider $searchProvider, protected TranslatorInterface $translator, protected PaginatorFactory $paginatorFactory, protected SearchApi $searchApi) {}
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/search/advanced/{name}", name="chill_main_advanced_search")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/search/advanced/{name}', name: 'chill_main_advanced_search')]
public function advancedSearchAction(mixed $name, Request $request)
{
try {
@@ -81,9 +79,7 @@ class SearchController extends AbstractController
);
}
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/search/advanced", name="chill_main_advanced_search_list")
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/search/advanced', name: 'chill_main_advanced_search_list')]
public function advancedSearchListAction(Request $request)
{
/** @var Chill\MainBundle\Search\SearchProvider $variable */
@@ -100,9 +96,7 @@ class SearchController extends AbstractController
return $this->render('@ChillMain/Search/choose_list.html.twig');
}
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/search.{_format}", name="chill_main_search", requirements={"_format"="html|json"}, defaults={"_format"="html"})
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/search.{_format}', name: 'chill_main_search', requirements: ['_format' => 'html|json'], defaults: ['_format' => 'html'])]
public function searchAction(Request $request, mixed $_format)
{
$pattern = trim((string) $request->query->get('q', ''));
@@ -192,9 +186,7 @@ class SearchController extends AbstractController
);
}
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/api/1.0/search.{_format}", name="chill_main_search_global", requirements={"_format"="json"}, defaults={"_format"="json"})
*/
#[\Symfony\Component\Routing\Annotation\Route(path: '/api/1.0/search.{_format}', name: 'chill_main_search_global', requirements: ['_format' => 'json'], defaults: ['_format' => 'json'])]
public function searchApi(Request $request, mixed $_format): JsonResponse
{
// TODO this is an incomplete implementation

View File

@@ -22,12 +22,7 @@ class TimelineCenterController extends AbstractController
{
public function __construct(protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private readonly Security $security) {}
/**
* @Route("/{_locale}/center/timeline",
* name="chill_center_timeline",
* methods={"GET"}
* )
*/
#[Route(path: '/{_locale}/center/timeline', name: 'chill_center_timeline', methods: ['GET'])]
public function centerAction(Request $request)
{
// collect reachable center for each group

View File

@@ -24,15 +24,7 @@ class UserApiController extends ApiController
{
public function __construct(private readonly ChillSecurity $security) {}
/**
* @Route(
* "/api/1.0/main/user-current-location.{_format}",
* name="chill_main_user_current_location",
* requirements={
* "_format": "json"
* }
* )
*/
#[Route(path: '/api/1.0/main/user-current-location.{_format}', name: 'chill_main_user_current_location', requirements: ['_format' => 'json'])]
public function currentLocation(mixed $_format): JsonResponse
{
if (!$this->isGranted('ROLE_USER')) {
@@ -47,15 +39,7 @@ class UserApiController extends ApiController
);
}
/**
* @Route(
* "/api/1.0/main/whoami.{_format}",
* name="chill_main_user_whoami",
* requirements={
* "_format": "json"
* }
* )
*/
#[Route(path: '/api/1.0/main/whoami.{_format}', name: 'chill_main_user_whoami', requirements: ['_format' => 'json'])]
public function whoami(mixed $_format): JsonResponse
{
return $this->json(

View File

@@ -31,7 +31,6 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -42,7 +41,7 @@ class UserController extends CRUDController
public function __construct(
private readonly LoggerInterface $logger,
private readonly ValidatorInterface $validator,
private readonly UserPasswordEncoderInterface $passwordEncoder,
private readonly \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface $passwordEncoder,
private readonly UserRepository $userRepository,
protected ParameterBagInterface $parameterBag,
private readonly TranslatorInterface $translator,
@@ -50,10 +49,7 @@ class UserController extends CRUDController
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry
) {}
/**
* @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter",
* name="admin_user_add_groupcenter")
*/
#[Route(path: '/{_locale}/admin/main/user/{uid}/add_link_groupcenter', name: 'admin_user_add_groupcenter')]
public function addLinkGroupCenterAction(Request $request, mixed $uid): Response
{
$em = $this->managerRegistry->getManager();
@@ -102,10 +98,7 @@ class UserController extends CRUDController
]);
}
/**
* @Route("/{_locale}/admin/main/user/{uid}/delete_link_groupcenter/{gcid}",
* name="admin_user_delete_groupcenter")
*/
#[Route(path: '/{_locale}/admin/main/user/{uid}/delete_link_groupcenter/{gcid}', name: 'admin_user_delete_groupcenter')]
public function deleteLinkGroupCenterAction(mixed $uid, mixed $gcid, Request $request): RedirectResponse
{
$em = $this->managerRegistry->getManager();
@@ -202,9 +195,8 @@ class UserController extends CRUDController
/**
* Displays a form to edit the user current location.
*
* @Route("/{_locale}/main/user/current-location/edit", name="chill_main_user_currentlocation_edit")
*/
#[Route(path: '/{_locale}/main/user/current-location/edit', name: 'chill_main_user_currentlocation_edit')]
public function editCurrentLocationAction(Request $request)
{
$user = $this->security->getUser();
@@ -234,9 +226,8 @@ class UserController extends CRUDController
/**
* Displays a form to edit the user password.
*
* @Route("/{_locale}/admin/user/{id}/edit_password", name="admin_user_edit_password")
*/
#[Route(path: '/{_locale}/admin/user/{id}/edit_password', name: 'admin_user_edit_password')]
public function editPasswordAction(User $user, Request $request)
{
$editForm = $this->createEditPasswordForm($user);
@@ -251,7 +242,7 @@ class UserController extends CRUDController
'user' => $user->getUsername(),
]);
$user->setPassword($this->passwordEncoder->encodePassword($user, $password));
$user->setPassword($this->passwordEncoder->hashPassword($user, $password));
$this->managerRegistry->getManager()->flush();
$this->addFlash('success', $this->translator->trans('Password successfully updated!'));
@@ -360,7 +351,7 @@ class UserController extends CRUDController
// for "new", encode the password
if ('new' === $action && $this->parameterBag->get('chill_main.access_user_change_password')) {
$entity->setPassword($this->passwordEncoder
->encodePassword($entity, $form['plainPassword']->getData()));
->hashPassword($entity, $form['plainPassword']->getData()));
}
// default behaviour

View File

@@ -33,9 +33,8 @@ final readonly class UserExportController
* @throws \League\Csv\CannotInsertRecord
* @throws \League\Csv\Exception
* @throws \League\Csv\UnavailableStream
*
* @Route("/{_locale}/admin/main/users/export/list.{_format}", requirements={"_format": "csv"}, name="chill_main_users_export_list")
*/
#[Route(path: '/{_locale}/admin/main/users/export/list.{_format}', requirements: ['_format' => 'csv'], name: 'chill_main_users_export_list')]
public function userList(Request $request, string $_format = 'csv'): StreamedResponse
{
if (!$this->security->isGranted('ROLE_ADMIN')) {
@@ -94,9 +93,8 @@ final readonly class UserExportController
* @throws \League\Csv\CannotInsertRecord
* @throws \League\Csv\Exception
* @throws \League\Csv\UnavailableStream
*
* @Route("/{_locale}/admin/main/users/export/permissions.{_format}", requirements={"_format": "csv"}, name="chill_main_users_export_permissions")
*/
#[Route(path: '/{_locale}/admin/main/users/export/permissions.{_format}', requirements: ['_format' => 'csv'], name: 'chill_main_users_export_permissions')]
public function userPermissionsList(string $_format = 'csv'): StreamedResponse
{
if (!$this->security->isGranted('ROLE_ADMIN')) {

View File

@@ -23,9 +23,7 @@ class UserJobScopeHistoriesController extends AbstractController
private readonly Environment $engine,
) {}
/**
* @Route("/{_locale}/admin/main/user/{id}/job-scope-history", name="admin_user_job_scope_history")
*/
#[Route(path: '/{_locale}/admin/main/user/{id}/job-scope-history', name: 'admin_user_job_scope_history')]
public function indexAction(User $user): Response
{
$jobHistories = $user->getUserJobHistoriesOrdered();

View File

@@ -32,9 +32,8 @@ final class UserProfileController extends AbstractController
/**
* User profile that allows editing of phonenumber and visualization of certain data.
*
* @Route("/{_locale}/main/user/my-profile", name="chill_main_user_profile")
*/
#[Route(path: '/{_locale}/main/user/my-profile', name: 'chill_main_user_profile')]
public function __invoke(Request $request)
{
if (!$this->security->isGranted('ROLE_USER')) {

View File

@@ -33,9 +33,8 @@ class WorkflowApiController
/**
* Return a list of workflow which are waiting an action for the user.
*
* @Route("/api/1.0/main/workflow/my", methods={"GET"})
*/
#[Route(path: '/api/1.0/main/workflow/my', methods: ['GET'])]
public function myWorkflow(Request $request): JsonResponse
{
if (!$this->security->isGranted('ROLE_USER') || !$this->security->getUser() instanceof User) {
@@ -72,9 +71,8 @@ class WorkflowApiController
/**
* Return a list of workflow which are waiting an action for the user.
*
* @Route("/api/1.0/main/workflow/my-cc", methods={"GET"})
*/
#[Route(path: '/api/1.0/main/workflow/my-cc', methods: ['GET'])]
public function myWorkflowCc(Request $request): JsonResponse
{
if (!$this->security->isGranted('ROLE_USER') || !$this->security->getUser() instanceof User) {
@@ -109,17 +107,13 @@ class WorkflowApiController
);
}
/**
* @Route("/api/1.0/main/workflow/{id}/subscribe", methods={"POST"})
*/
#[Route(path: '/api/1.0/main/workflow/{id}/subscribe', methods: ['POST'])]
public function subscribe(EntityWorkflow $entityWorkflow, Request $request): Response
{
return $this->handleSubscription($entityWorkflow, $request, 'subscribe');
}
/**
* @Route("/api/1.0/main/workflow/{id}/unsubscribe", methods={"POST"})
*/
#[Route(path: '/api/1.0/main/workflow/{id}/unsubscribe', methods: ['POST'])]
public function unsubscribe(EntityWorkflow $entityWorkflow, Request $request): Response
{
return $this->handleSubscription($entityWorkflow, $request, 'unsubscribe');

View File

@@ -40,9 +40,7 @@ class WorkflowController extends AbstractController
{
public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly ValidatorInterface $validator, private readonly PaginatorFactory $paginatorFactory, private readonly Registry $registry, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
/**
* @Route("/{_locale}/main/workflow/create", name="chill_main_workflow_create")
*/
#[Route(path: '/{_locale}/main/workflow/create', name: 'chill_main_workflow_create')]
public function create(Request $request): Response
{
if (!$request->query->has('entityClass')) {
@@ -86,9 +84,7 @@ class WorkflowController extends AbstractController
return $this->redirectToRoute('chill_main_workflow_show', ['id' => $entityWorkflow->getId()]);
}
/**
* @Route("/{_locale}/main/workflow/{id}/delete", name="chill_main_workflow_delete")
*/
#[Route(path: '/{_locale}/main/workflow/{id}/delete', name: 'chill_main_workflow_delete')]
public function delete(EntityWorkflow $entityWorkflow, Request $request): Response
{
$this->denyAccessUnlessGranted(EntityWorkflowVoter::DELETE, $entityWorkflow);
@@ -113,9 +109,7 @@ class WorkflowController extends AbstractController
]);
}
/**
* @Route("/{_locale}/main/workflow-step/{id}/access_key", name="chill_main_workflow_grant_access_by_key")
*/
#[Route(path: '/{_locale}/main/workflow-step/{id}/access_key', name: 'chill_main_workflow_grant_access_by_key')]
public function getAccessByAccessKey(EntityWorkflowStep $entityWorkflowStep, Request $request): Response
{
if (null === $accessKey = $request->query->get('accessKey', null)) {
@@ -143,9 +137,8 @@ class WorkflowController extends AbstractController
/**
* Previous workflows where the user has applyed a transition.
*
* @Route("/{_locale}/main/workflow/list/previous_transitionned", name="chill_main_workflow_list_previous_transitionned")
*/
#[Route(path: '/{_locale}/main/workflow/list/previous_transitionned', name: 'chill_main_workflow_list_previous_transitionned')]
public function myPreviousWorkflowsTransitionned(Request $request): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
@@ -173,9 +166,8 @@ class WorkflowController extends AbstractController
/**
* Previous workflows where the user was mentioned, but did not give any reaction.
*
* @Route("/{_locale}/main/workflow/list/previous_without_reaction", name="chill_main_workflow_list_previous_without_reaction")
*/
#[Route(path: '/{_locale}/main/workflow/list/previous_without_reaction', name: 'chill_main_workflow_list_previous_without_reaction')]
public function myPreviousWorkflowsWithoutReaction(Request $request): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
@@ -201,9 +193,7 @@ class WorkflowController extends AbstractController
);
}
/**
* @Route("/{_locale}/main/workflow/list/cc", name="chill_main_workflow_list_cc")
*/
#[Route(path: '/{_locale}/main/workflow/list/cc', name: 'chill_main_workflow_list_cc')]
public function myWorkflowsCc(Request $request): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
@@ -228,9 +218,7 @@ class WorkflowController extends AbstractController
);
}
/**
* @Route("/{_locale}/main/workflow/list/dest", name="chill_main_workflow_list_dest")
*/
#[Route(path: '/{_locale}/main/workflow/list/dest', name: 'chill_main_workflow_list_dest')]
public function myWorkflowsDest(Request $request): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
@@ -255,9 +243,7 @@ class WorkflowController extends AbstractController
);
}
/**
* @Route("/{_locale}/main/workflow/list/subscribed", name="chill_main_workflow_list_subscribed")
*/
#[Route(path: '/{_locale}/main/workflow/list/subscribed', name: 'chill_main_workflow_list_subscribed')]
public function myWorkflowsSubscribed(Request $request): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
@@ -282,9 +268,7 @@ class WorkflowController extends AbstractController
);
}
/**
* @Route("/{_locale}/main/workflow/{id}/show", name="chill_main_workflow_show")
*/
#[Route(path: '/{_locale}/main/workflow/{id}/show', name: 'chill_main_workflow_show')]
public function show(EntityWorkflow $entityWorkflow, Request $request): Response
{
$this->denyAccessUnlessGranted(EntityWorkflowVoter::SEE, $entityWorkflow);