apply rector rules: symfony **UP TO** 44

This commit is contained in:
2023-07-28 01:52:53 +02:00
parent b6a094aeee
commit c20f65eebb
88 changed files with 211 additions and 320 deletions

View File

@@ -36,7 +36,7 @@ class AbsenceController extends AbstractController
$em = $this->getDoctrine()->getManager();
$em->flush();
return $this->redirect($this->generateUrl('chill_main_user_absence_index'));
return $this->redirectToRoute('chill_main_user_absence_index');
}
return $this->render('@ChillMain/Menu/absence.html.twig', [
@@ -60,6 +60,6 @@ class AbsenceController extends AbstractController
$em = $this->getDoctrine()->getManager();
$em->flush();
return $this->redirect($this->generateUrl('chill_main_user_absence_index'));
return $this->redirectToRoute('chill_main_user_absence_index');
}
}

View File

@@ -31,12 +31,12 @@ class CenterController extends AbstractController
$form = $this->createCreateForm($center);
$form->handleRequest($request);
if ($form->isValid()) {
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($center);
$em->flush();
return $this->redirect($this->generateUrl('admin_center'));
return $this->redirectToRoute('admin_center');
}
return $this->render('@ChillMain/Center/new.html.twig', [
@@ -128,10 +128,10 @@ class CenterController extends AbstractController
$editForm = $this->createEditForm($center);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
if ($editForm->isSubmitted() && $editForm->isValid()) {
$em->flush();
return $this->redirect($this->generateUrl('admin_center_edit', ['id' => $id]));
return $this->redirectToRoute('admin_center_edit', ['id' => $id]);
}
return $this->render('@ChillMain/Center/edit.html.twig', [

View File

@@ -29,7 +29,7 @@ class DefaultController extends AbstractController
public function indexWithoutLocaleAction()
{
return $this->redirect($this->generateUrl('chill_main_homepage'));
return $this->redirectToRoute('chill_main_homepage');
}
public function testAction()

View File

@@ -361,13 +361,11 @@ class ExportController extends AbstractController
$this->session->set('export_step', $data);
//redirect to next step
return $this->redirect(
$this->generateUrl('chill_main_export_new', [
'step' => $this->getNextStep('export', $export),
'alias' => $alias,
'from_saved' => $request->get('from_saved', '')
])
);
return $this->redirectToRoute('chill_main_export_new', [
'step' => $this->getNextStep('export', $export),
'alias' => $alias,
'from_saved' => $request->get('from_saved', '')
]);
}
$this->logger->debug('form export is invalid', [
'location' => __METHOD__, ]);
@@ -413,14 +411,11 @@ class ExportController extends AbstractController
);
//redirect to next step
return $this->redirect($this->generateUrl(
'chill_main_export_new',
[
'alias' => $alias,
'step' => $this->getNextStep('formatter', $export),
'from_saved' => $request->get('from_saved', ''),
]
));
return $this->redirectToRoute('chill_main_export_new', [
'alias' => $alias,
'step' => $this->getNextStep('formatter', $export),
'from_saved' => $request->get('from_saved', ''),
]);
}
}

View File

@@ -114,8 +114,8 @@ class PasswordController extends AbstractController
if (null === $user) {
$this->eventDispatcher->dispatch(
PasswordRecoverEvent::INVALID_TOKEN,
new PasswordRecoverEvent($token, null, $request->getClientIp())
new PasswordRecoverEvent($token, null, $request->getClientIp()),
PasswordRecoverEvent::INVALID_TOKEN
);
throw $this->createNotFoundException(sprintf('User %s not found', $username));
@@ -123,8 +123,8 @@ class PasswordController extends AbstractController
if (true !== $this->tokenManager->verify($hash, $token, $user, $timestamp)) {
$this->eventDispatcher->dispatch(
PasswordRecoverEvent::INVALID_TOKEN,
new PasswordRecoverEvent($token, $user, $request->getClientIp())
new PasswordRecoverEvent($token, $user, $request->getClientIp()),
PasswordRecoverEvent::INVALID_TOKEN
);
return new Response('Invalid token', Response::HTTP_FORBIDDEN);
@@ -214,16 +214,16 @@ class PasswordController extends AbstractController
);
$this->eventDispatcher->dispatch(
PasswordRecoverEvent::ASK_TOKEN_SUCCESS,
new PasswordRecoverEvent(null, $user, $request->getClientIp())
new PasswordRecoverEvent(null, $user, $request->getClientIp()),
PasswordRecoverEvent::ASK_TOKEN_SUCCESS
);
return $this->redirectToRoute('password_request_recover_confirm');
}
} elseif ($form->isSubmitted() && false === $form->isValid()) {
$this->eventDispatcher->dispatch(
PasswordRecoverEvent::ASK_TOKEN_INVALID_FORM,
new PasswordRecoverEvent(null, null, $request->getClientIp())
new PasswordRecoverEvent(null, null, $request->getClientIp()),
PasswordRecoverEvent::ASK_TOKEN_INVALID_FORM
);
}

View File

@@ -83,10 +83,7 @@ final class PermissionsGroupController extends AbstractController
$this->translator->trans('The permissions have been added')
);
return $this->redirect($this->generateUrl(
'admin_permissionsgroup_edit',
['id' => $id]
));
return $this->redirectToRoute('admin_permissionsgroup_edit', ['id' => $id]);
}
foreach ($violations as $error) {
@@ -146,10 +143,7 @@ final class PermissionsGroupController extends AbstractController
$this->em->persist($permissionsGroup);
$this->em->flush();
return $this->redirect($this->generateUrl(
'admin_permissionsgroup_edit',
['id' => $permissionsGroup->getId()]
));
return $this->redirectToRoute('admin_permissionsgroup_edit', ['id' => $permissionsGroup->getId()]);
}
return $this->render('@ChillMain/PermissionsGroup/new.html.twig', [
@@ -187,10 +181,7 @@ final class PermissionsGroupController extends AbstractController
])
);
return $this->redirect($this->generateUrl(
'admin_permissionsgroup_edit',
['id' => $pgid]
));
return $this->redirectToRoute('admin_permissionsgroup_edit', ['id' => $pgid]);
}
$this->em->flush();
@@ -214,10 +205,7 @@ final class PermissionsGroupController extends AbstractController
);
}
return $this->redirect($this->generateUrl(
'admin_permissionsgroup_edit',
['id' => $pgid]
));
return $this->redirectToRoute('admin_permissionsgroup_edit', ['id' => $pgid]);
}
/**
@@ -362,7 +350,7 @@ final class PermissionsGroupController extends AbstractController
if ($editForm->isValid()) {
$this->em->flush();
return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', ['id' => $id]));
return $this->redirectToRoute('admin_permissionsgroup_edit', ['id' => $id]);
}
$deleteRoleScopesForm = [];

View File

@@ -31,12 +31,12 @@ class ScopeController extends AbstractController
$form = $this->createCreateForm($scope);
$form->handleRequest($request);
if ($form->isValid()) {
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($scope);
$em->flush();
return $this->redirect($this->generateUrl('admin_scope'));
return $this->redirectToRoute('admin_scope');
}
return $this->render('@ChillMain/Scope/new.html.twig', [
@@ -128,10 +128,10 @@ class ScopeController extends AbstractController
$editForm = $this->createEditForm($scope);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
if ($editForm->isSubmitted() && $editForm->isValid()) {
$em->flush();
return $this->redirect($this->generateUrl('admin_scope_edit', ['id' => $id]));
return $this->redirectToRoute('admin_scope_edit', ['id' => $id]);
}
return $this->render('@ChillMain/Scope/edit.html.twig', [

View File

@@ -74,10 +74,7 @@ class UserController extends CRUDController
$returnPathParams = $request->query->has('returnPath') ?
['returnPath' => $request->query->get('returnPath')] : [];
return $this->redirect($this->generateUrl(
'chill_crud_admin_user_edit',
array_merge(['id' => $uid], $returnPathParams)
));
return $this->redirectToRoute('chill_crud_admin_user_edit', array_merge(['id' => $uid], $returnPathParams));
}
foreach ($this->validator->validate($user) as $error) {
@@ -123,7 +120,7 @@ class UserController extends CRUDController
} catch (RuntimeException $ex) {
$this->addFlash('error', $this->get('translator')->trans($ex->getMessage()));
return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', ['id' => $uid]));
return $this->redirectToRoute('chill_crud_admin_user_edit', ['id' => $uid]);
}
$em->flush();
@@ -131,7 +128,7 @@ class UserController extends CRUDController
$this->addFlash('success', $this->get('translator')
->trans('The permissions where removed.'));
return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', ['id' => $uid]));
return $this->redirectToRoute('chill_crud_admin_user_edit', ['id' => $uid]);
}
public function edit(Request $request, $id): Response