Fix: fix usage of scope picker with unactives scopes

This commit is contained in:
Julien Fastré 2023-04-19 12:58:40 +02:00
parent cb1ea8c622
commit a1421ea99f
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -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');