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

@@ -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