From a1421ea99f2c502f46f3ffbf93a73eb0e9963aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 19 Apr 2023 12:58:40 +0200 Subject: [PATCH] Fix: fix usage of scope picker with unactives scopes --- .../Form/Type/ScopePickerType.php | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php index 79ed6df40..6f1a5837f 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php @@ -60,16 +60,17 @@ class ScopePickerType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $items = array_filter( - $this->authorizationHelper->getReachableScopes( - $this->security->getUser(), - $options['role'] instanceof Role ? $options['role']->getRole() : $options['role'], - $options['center'] - ), - static function (Scope $s) { - return $s->isActive(); - } - ); + $items = array_values( + array_filter( + $this->authorizationHelper->getReachableScopes( + $this->security->getUser(), + $options['role'] instanceof Role ? $options['role']->getRole() : $options['role'], + $options['center'] + ), + static function (Scope $s) { + return $s->isActive(); + } + )); if (0 === count($items)) { throw new RuntimeException('no scopes are reachable. This form should not be shown to user');