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) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$items = array_filter( $items = array_values(
$this->authorizationHelper->getReachableScopes( array_filter(
$this->security->getUser(), $this->authorizationHelper->getReachableScopes(
$options['role'] instanceof Role ? $options['role']->getRole() : $options['role'], $this->security->getUser(),
$options['center'] $options['role'] instanceof Role ? $options['role']->getRole() : $options['role'],
), $options['center']
static function (Scope $s) { ),
return $s->isActive(); static function (Scope $s) {
} 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');