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,7 +60,8 @@ class ScopePickerType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$items = array_filter( $items = array_values(
array_filter(
$this->authorizationHelper->getReachableScopes( $this->authorizationHelper->getReachableScopes(
$this->security->getUser(), $this->security->getUser(),
$options['role'] instanceof Role ? $options['role']->getRole() : $options['role'], $options['role'] instanceof Role ? $options['role']->getRole() : $options['role'],
@ -69,7 +70,7 @@ class ScopePickerType extends AbstractType
static function (Scope $s) { static function (Scope $s) {
return $s->isActive(); return $s->isActive();
} }
); ));
if (0 === count($items)) { if (0 === count($items)) {
throw new RuntimeException('no scopes are reachable. This form should not be shown to user'); throw new RuntimeException('no scopes are reachable. This form should not be shown to user');