From 7278a5f3faa730ee0d15b3069404197e31ff0a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 27 May 2022 16:24:55 +0200 Subject: [PATCH] fix strict typing and do not show link to edit password in user list --- phpstan-deprecations.neon | 5 ----- src/Bundle/ChillMainBundle/Controller/UserController.php | 5 +++++ src/Bundle/ChillMainBundle/Form/UserType.php | 1 + .../ChillMainBundle/Resources/views/User/index.html.twig | 4 ++++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/phpstan-deprecations.neon b/phpstan-deprecations.neon index 2de8b8bc8..42981a551 100644 --- a/phpstan-deprecations.neon +++ b/phpstan-deprecations.neon @@ -471,11 +471,6 @@ parameters: count: 1 path: src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php - - - message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" - count: 1 - path: src/Bundle/ChillMainBundle/Form/UserType.php - - message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" count: 2 diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 4eb22c5d3..b6ded6653 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -344,6 +344,11 @@ class UserController extends CRUDController ), ] ); + } elseif ('index' === $action) { + return array_merge( + ['allow_change_password' => $this->parameterBag->get('chill_main.access_user_change_password')], + $defaultTemplateParameters + ); } // default behaviour diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index 9e7da7a89..34c49bc38 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -112,6 +112,7 @@ class UserType extends AbstractType }, ]); + // @phpstan-ignore-next-line if ($options['is_creation'] && $this->parameterBag->get('chill_main.access_user_change_password')) { $builder->add('plainPassword', RepeatedType::class, [ 'mapped' => false, diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig index 1d254abb9..ec93cf8a7 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig @@ -50,9 +50,13 @@
  • + + {% if allow_change_password is same as(true) %}
  • + {% endif %} + {% if is_granted('ROLE_ALLOWED_TO_SWITCH') %}